import os, sys
from PIL import Image
path = os.getcwd().replace("\\", "/")
for file in os.listdir(path):
if ".jpg" in file:
new_file = file.split(".")[-2]+".png"
print(new_file)
new_image = Image.open(path +"/"+ file)
new_image.save(path +"/"+ new_file)
原理很简单,就是用PIL.Image打开后再保存为另一种格式。