Python 批量更改图片后缀
Python 批量更改图片后缀
import os file_path = r"E:\DATASET\Mine_Helmet\images\val_hou\val" files = os.listdir(file_path) for file in files: if file.endswith('png'): # 要指明重命名之后的路径 src = os.path.join(file_path, file) r_name = file.split('.')[0] + '.jpg' dct = os.path.join(file_path, r_name) os.rename(src, dct)