🌐
经济型:买域名、轻量云服务器、用途:游戏 网站等 《腾讯云》特点:特价机便宜 适合初学者用
点我优惠购买
🚀
拓展型:买域名、轻量云服务器、用途:游戏 网站等 《阿里云》特点:中档服务器便宜 域名备案事多
点我优惠购买
🛡️
稳定型:买域名、轻量云服务器、用途:游戏 网站等 《西部数码》 特点:比上两家略贵但是稳定性超好事也少
点我优惠购买
import os
from PIL import Image
import tkinter as tk
from tkinter import filedialog, messagebox
def convert_webp_to_png(directory_path):
converted_count = 0
for root, dirs, files in os.walk(directory_path):
for file in files:
if file.endswith('.webp'):
webp_path = os.path.join(root, file)
png_path = os.path.splitext(webp_path)[0] + '.png'
try:
image = Image.open(webp_path)
image.save(png_path, 'PNG')
os.remove(webp_path)
converted_count += 1
except Exception as e:
messagebox.showerror("转换错误", f"文件'{file}'转换失败:{str(e)}")
messagebox.showinfo("转换完成", f"成功转换 {converted_count} 个文件!")
def select_directory():
directory = filedialog.askdirectory()
if directory:
directory_label.config(text=directory)
def convert_files():
directory_path = directory_label.cget("text")
if directory_path:
convert_webp_to_png(directory_path)
# 创建主窗口
window = tk.Tk()
window.title("WebP转换PNG- - - -云时出品- -")
window.geometry("350x100")
# 创建选择目录按钮
select_button = tk.Button(window, text="选择目录", command=select_directory)
select_button.pack()
# 创建显示目录路径的标签
directory_label = tk.Label(window, text="")
directory_label.pack()
# 创建执行转换按钮
convert_button = tk.Button(window, text="执行转换", command=convert_files)
convert_button.pack()
# 显示窗口
window.mAInloop()上面是源代码 下面是生成后的文件

此部分为隐藏内容,请输入验证码后查看
扫描右侧图片,或微信搜索 “ 网络财神 ” 或 “ newjixi ” 关注本站官方公众号,回复 “ 验证码 ” ,获取验证密码。
文章版权声明:除非注明,否则均为AI虎哥的工具库原创文章,转载或复制请以超链接形式并注明出处。



还没有评论,来说两句吧...