Python 3中的tkFileDialog模塊在哪裏?問題Choosing a file in Python with simple Dialog參考使用模塊:在Python3中選擇文件
from Tkinter import Tk
from tkFileDialog import askopenfilename
,但使用在Python 3(改變的Tkinter Tkinter的到後)獲得:
Traceback (most recent call last):
File "C:\Documents and Settings\me\My Documents\file.pyw", line 5, in <module>
import tkFileDialog
ImportError: No module named tkFileDialog
蟒蛇2.7.2 DOC(docs.python.org)說:
tkFileDialog
Common dialogs to allow the user to specify a file to open or save.
These have been renamed as well in Python 3.0; they were all made submodules of the new tkinter package.
,但它沒有給出暗示新的名稱是什麼,以及搜索tkFileDialog和askopenfilename在3.2.2文檔都沒有返回值(甚至不日的映射Ë舊名稱到新的子模塊名稱)
試圖明顯沒有做插孔:
from tkinter import askopenfilename, asksaveasfilename
ImportError: cannot import name askopenfilename
你怎麼稱呼askopenfilename()相當於在Python 3?
'filedialog'不是通過'從Tkinter的進口*'可用。你必須這樣做'從tkinter.filedialog導入askopenfilename'。 – Shule
我剛剛添加了root.withdraw()調用,以刪除討厭的窗口。 我的代碼在Python 3.4中工作正常 – user1741137