pyhon3 文件名批量转换

来源:互联网 发布:淘宝新店铺的扶持 编辑:程序博客网 时间:2024/05/16 13:52
import osimport reimport stringpath = 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)


0 0
原创粉丝点击