詢問用戶要打開的文件
# 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