对文件后缀名进行修改
import os
def file1_name(file_dir):
'''
批量修改文件后缀名
'''
for root, dirs, files in os.walk(file_dir):
for file in files:
oldname = os.path.splitext(file)
if oldname[1] == '.jpg':
newname = oldname[0] + ".png"
os.rename(str(root)+'\\'+file,str(root)+'\\'+newname)
file1_name('E:\\GTEA_Dataset\\png\\002')