py_bmptojpg
#***************************************************************
import os
from PIL import Image
file_path = os.getcwd()
trans_count = 0
def b2j(file_path):
for fileName in os.listdir(file_path):
if os.path.splitext(fileName)[1] == '.bmp':#指定bmp文件后缀
newFileName = fileName[0:fileName.find(".")]+".jpg"
im = Image.open(file_path+"/"+fileName)
im.save(file_path+"/"+newFileName)
global trans_count
trans_count += 1
print(f"transform_count:{trans_count}")
b2j(file_path)
print('bmp to jpg has been completed!')
浙公网安备 33010602011771号