python:询问用户要打开的文件:tkinter.filedialog.askopenfilename

询问用户要打开的文件

# 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
posted on 2021-01-22 15:33  摸鱼time  阅读(2078)  评论(0编辑  收藏  举报