import tkinter.filedialog
from tkinter import *
def func1():
a=tkinter.filedialog.asksaveasfilename()#返回文件名
print(a)
a =tkinter.filedialog.asksaveasfile()#會創(chuàng)建文件
print(a)
a =tkinter.filedialog.askopenfilename()#返回文件名
print(a)
a =tkinter.filedialog.askopenfile()#返回文件流對象
print(a)
a =tkinter.filedialog.askdirectory()#返回目錄名
print(a)
a =tkinter.filedialog.askopenfilenames()#可以返回多個文件名
print(a)
a =tkinter.filedialog.askopenfiles()#多個文件流對象
print(a)
root=Tk()
root.title("filedialog")
btn1=Button(root,text="click",command=func1)
btn1.pack()
root.mainloop()