您可以使用 Pillow 模块执行此操作(但默认情况下它不随 Python 一起提供,请使用pip install pillow)from PIL import Image # import the PIL.Image moduleimg = Image.open("image.webp") # open your imageimg.save("image2.webp", quality=70) # save the image with the given quality