Mô-đun tkFileDialog trong Python 3 ở đâu? Câu hỏi đặt ra tài liệu tham khảo Choosing a file in Python with simple Dialog module sử dụng:Chọn tệp trong Python3
from Tkinter import Tk
from tkFileDialog import askopenfilename
nhưng sử dụng đó (sau khi thay đổi Tkinter để Tkinter) trong Python 3 được:
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
Các python 2.7.2 doc (docs.python.org) nói:
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.
nhưng nó mang lại không có gợi ý gì những cái tên mới sẽ là, và tìm kiếm tkFileDialog và askopenfilename trong 3.2.2 docs trả gì cả (thậm chí không phải là một ánh xạ từ thứ e tên cũ sang tên submodule mới)
Cố gắng rõ ràng không làm jack:.
from tkinter import askopenfilename, asksaveasfilename
ImportError: cannot import name askopenfilename
Làm thế nào để bạn gọi tương đương với askopenfilename() trong Python 3?
'filedialog' không có sẵn thông qua' từ Tkinter nhập khẩu * '. Bạn phải làm như 'từ tkinter.filedialog import askopenfilename'. – Shule
Tôi vừa thêm lệnh gọi root.withdraw() để xóa cửa sổ pesky. Mã của tôi hoạt động tốt trong Python 3.4 – user1741137