询问用户要打开的文件
# a program to show the file's name user selected by the method 'askopenfilename'.
from tkinter.filedialog import askopenfilename
import os
file = askopenfilename()
filename = os.path.basename(file)
print('The name of the file you just selected is:'+ filename)
文件选择
运行结果
# The name of the file you just selected is:kv_first_time_takeover