📜  如何在python代码示例中打开对话框以选择文件夹

📅  最后修改于: 2022-03-11 14:47:19.445000             🧑  作者: Mango

代码示例1
>>> from tkinter import Tk, filedialog
>>>
>>> root = Tk() # pointing root to Tk() to use it as Tk() in program.
>>> root.withdraw() # Hides small tkinter window.
''
>>> root.attributes('-topmost', True) # Opened windows will be active. above all windows despite of selection.
''
>>> open_file = filedialog.askdirectory() # Returns opened path as str
>>> print(open_file) 
C:/Users/User/Music
>>>