Python中使用Tkinter对话框选择单个文件、多个文件或文件夹,简易版
import tkinter as tk
from tkinter import filedialog
import os
app_win = tk.Tk()
app_win.withdraw()
# select a folder
folder_path = filedialog.askdirectory(parent=app_win)
if folder_path:
pass
else: # if no folder was chosen, askdirectory return null str
raise SystemExit('No folder chosen')
# selsect a single file
file_path = filedialog.askopenfilename(parent=app_win)
# select one or more flles, return a tuple
files_tuple = filedialog.askopenfilenames(parent=app_win)