import os
pathdir = r"/home/csj/task/task1/train"
for file in os.listdir(pathdir):
ext = os.path.splitext(file)
if ext[1] == '.jpg':
newext = '.png'
filename = ext[0] + newext
oldfile = os.path.join(pathdir,file)
newfile = os.path.join(pathdir,filename)
os.rename(oldfile,newfile)
python更改图片后缀jpg->png
最新推荐文章于 2024-03-13 13:44:10 发布