"使用 Python 3.7 编写脚本,读取 Win10 系统中 U盘历史记录,并用图形界面展示内容:" "要实现这个功能,你可以使用 tkinter 库来创建图形界面,使用 os 库来读取 U盘历史记录。" "以下是一个简单的示例代码:" "python\nimport os\nimport tkinter as tk\nfrom tkinter import ttk\n\ndef get_usb_history():\n # 获取 U盘历史记录\n history = []\n for drive in range(ord('A'), ord('Z')+1):\n drive = chr(drive)\n if os.path.exists(drive+':\'):\n history.append(drive)\n return history\n\ndef show_usb_history():\n # 创建图形界面\n root = tk.Tk()\n root.title("U盘历史记录")\n \n usb_history = get_usb_history()\n \n # 创建列表框\n listbox = tk.Listbox(root)\n listbox.pack(fill=tk.BOTH, expand=True)\n \n for drive in usb_history:\n listbox.insert(tk.END, drive)\n \n root.mainloop()\n\n# 运行图形界面\nshow_usb_history()\n" "运行这个脚本,将会显示一个窗口,其中列出了系统中所有已连接的 U盘驱动器的字母。"


原文地址: https://www.cveoy.top/t/topic/pHxl 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录