如何使用 GUI 在 Python 3 中打开目录? [英] How do I use a GUI to open a directory in Python 3?
本文介绍了如何使用 GUI 在 Python 3 中打开目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在Python中找到几个文件所在目录的字符串值.然后,我计划使用 os.listdir
继续编写脚本.我试过使用 tkFileDialog
来使用 askdirectory
,但不是运气.
I want to find the string value of the directory in Python where a few files are located. Then, I plan on using os.listdir
to continue on with the script. I've tried using tkFileDialog
to use askdirectory
, but not luck.
推荐答案
tkFileDialog 随 Python 3.x 改变,现在是 tkinter.filedialog
,tkinter
tkFileDialog changed with Python 3.x, it's now tkinter.filedialog
, a module of tkinter
导入方法如下:
from tkinter.filedialog import askdirectory
folder = askdirectory()
参考:http://docs.python.org/3.0/library/tkinter.html#tkinter-modules
这篇关于如何使用 GUI 在 Python 3 中打开目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文