pyhon3 文件名批量转换

import os
import re
import string
path = os.getcwd()
print("current file path",path)
files = os.listdir('D:\\1')
 
for name in files:
    a = os.path.splitext(name)
    if a[1] == '.txt': 
        newname = a[0]+'.py' 
        print (name,newname)
        os.rename(name,newname)


猜你喜欢

转载自blog.csdn.net/weixinyi21cn/article/details/49834755