要实现这个功能,你可以使用tkinter库来创建图形界面,使用os库来读取U盘历史记录。

以下是一个简单的示例代码:

import os
import tkinter as tk
from tkinter import ttk

def get_usb_history():
    # 获取U盘历史记录
    history = []
    for drive in range(ord('A'), ord('Z')+1):
        drive = chr(drive)
        if os.path.exists(drive+':\\'):
            history.append(drive)
    return history

def show_usb_history():
    # 创建图形界面
    root = tk.Tk()
    root.title("U盘历史记录")
    
    usb_history = get_usb_history()
    
    # 创建列表框
    listbox = tk.Listbox(root)
    listbox.pack(fill=tk.BOTH, expand=True)
    
    for drive in usb_history:
        listbox.insert(tk.END, drive)
    
    root.mainloop()

# 运行图形界面
show_usb_history()

运行这个脚本,将会显示一个窗口,其中列出了系统中所有已连接的U盘驱动器的字母

使用python37编写脚本读取win10系统中U盘历史记录并用图形界面展示

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

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