import os
# 图片所在路径
root_path = "license_plate/green/"
filename_list = os.listdir(root_path)
for filename in filename_list:
if filename.endswith('.jpg'):
src_img_path = os.path.join(os.path.abspath(root_path), filename)
dst_img_path = os.path.join(os.path.abspath(root_path), filename.split('_')[1])
try:
os.rename(src_img_path, dst_img_path)
print('converting %s to %s ...' % (src_img_path, dst_img_path))
except:
continue