复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17# -*- coding: utf-8 -*- import os #设定文件路径 path=''#在此处输入文件路径 i=1 #对目录下的文件进行遍历 for file in os.listdir(path): #判断是否是文件 if os.path.isfile(os.path.join(path,file))==True: #设置新文件名 new_name=file.replace(file,"%d.jpg"%i) #以.jpg为例 #重命名 os.rename(os.path.join(path,file),os.path.join(path,new_name)) i+=1 #结束 print ("End")
最后
以上就是瘦瘦银耳汤最近收集整理的关于Python对一个文件夹的所有文件修改格式。的全部内容,更多相关Python对一个文件夹内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复