“代码暂存”的版本间差异

来自橘猪小站
跳到导航 跳到搜索
第30行: 第30行:


         # 修改序号加2并格式化为不带前导零的字符串
         # 修改序号加2并格式化为不带前导零的字符串
         new_index = str(index + 1)
         new_index = str(index + 2)


         # 构造新的文件名
         # 构造新的文件名

2023年6月28日 (三) 15:13的版本

  • Arctime Pro字幕通用样式
Style: SUBTITLE,阿里巴巴普惠体 H,75,&H0000B3FF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100.0,100.0,0.0,0.0,1,2.0,2.8846154,2,10,10,40,1
    • 紫色版
Style: StyleName,阿里巴巴普惠体 H,75,&H00F56F8B,&H000000FF,&H00790743,&H00790743,0,0,0,0,100.0,100.0,0.0,0.0,1,2.0,2.5,2,10,10,59,1
  • PPT导出1080P 60FPS的宏
Sub PowerPointVideo()
If ActivePresentation.CreateVideoStatus <> ppMediaTaskStatusInProgress Then
ActivePresentation.CreateVideo FileName:=Environ("USERPROFILE") & "\Desktop\Your PowerPoint Video.mp4", _
UseTimingsAndNarrations:=True, _
VertResolution:=1080, _
FramesPerSecond:=60, _
Quality:=100
Else: MsgBox "There is another conversion to video in progress"
End If
End Sub
  • 将多个重复命名编号不同的文件名称进行修改

我现在有image001.png、image002.png、image003.png到image578.png的文件。需要让他们后面的序号全部加2并且去掉前面的00格式,如image001.png要改为image3.png。

import os
import shutil
# 遍历目录下的文件
directory = "./your_directory_path"  # 替换为实际的目录路径
destination_directory = "./your_directory_path"  # 替换为实际的目标文件目录路径
for filename in os.listdir(directory):
    if filename.startswith("image"):
        # 提取序号部分并将其转换为整数
        index = int(filename[5:8])

        # 修改序号加2并格式化为不带前导零的字符串
        new_index = str(index + 2)

        # 构造新的文件名
        new_filename = "image" + new_index + ".png"

        # 创建原文件的路径和新文件的路径
        old_path = os.path.join(directory, filename)
        new_path = os.path.join(destination_directory, new_filename)

        # 重命名文件
        os.rename(old_path, new_path)