import os
path = "C:\\Users\\sunxi\\Documents\\地下城与勇士\\ScreenShot"
file_names = os.listdir(path)
print(file_names)
for i , file_names in enumerate(file_names,):
# structure full of images path
# 构造 完整 的 图像 路径
old_file_path = os.path.join(path, file_names)
new_file_name = f"{i+1}.jpg"
# sava to path inside,new_file_name is neo file name
# 保存到path 里 是 新的 文件名
new_file_path = os.path.join(path, new_file_name)
# rechristen file
os.rename(old_file_path, new_file_path)
print("处理完成")
python os库
最新推荐文章于 2024-08-15 01:55:01 发布