from os import *
from PIL import Image
PATH = r"C:\Users\Administrator\Desktop"
for root, dirs, files in walk(PATH):
for f in files:
if path.splitext(f)[1] == ".webp":
img = Image.open(f)
img.load()
img.save(f[0:-5] + ".jpg")
remove(f)
这应该是最简洁的了,不过此代码需要在PATH路径下运行,也就是要跟图片的路径一样才行