我不喜欢这看起来如何或为什么它不起作用
import tkinter
from tkinter.filedialog import askopenfilename
root = tkinter.Tk()
filename = tkinter.filedialog.askopenfilename(
initialdir="E://",
title="choose file",
filetypes=(
("xhtml files","*.xhtml"),
("all files","*.*")
)
)
如果有比tkinter更好的方法,请建议。
答案 0 :(得分:1)
对我来说很好:
fedorov$ python3
Python 3.6.0 (default, Dec 24 2016, 08:01:42)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter
>>> from tkinter.filedialog import askopenfilename
>>> root = tkinter.Tk()
>>> tkinter.filedialog.askopenfilename(initialdir = "E://",title = "choose file",filetypes = (("xhtml files","*.xhtml"),("all files","*.*")))
'/Users/fedorov/Desktop/IMG_0656.jpg.xhtml'
你有什么期待?