图像识别项目中拿到的图片后缀名有的为jepg、jpg、png,往往需要统一后缀名,用一小段代码即可以实现,如下:
import os
src = 'collect_summary/'
num = 0
for file in os.listdir(src):
new_name = 'newname' + str(num) + '.png'
os.rename(os.path.join(src, file), os.path.join(src, new_name))
num += 1
print(file,"-->", new_name)