您现在的位置是:课程教程文章
python怎么打开文件对话框
2023-12-18 22:01课程教程文章 人已围观
可以使用tkinter.filedialog模块中的askopenfilename函数来实现,tkinter是python自带的GUI,通过askopenfilename函数打开选择文件对话框,代码如下:
import tkinter.filedialog fn=tkinter.filedialog.askopenfilename(title='选择一个文件', filetypes=[('所有文件','.*'),('文本文件','.txt')]) print(fn)
相关推荐:《Python教程》
效果如下:
函数说明:
askopenfilename(**options)
Ask for a filename to open
title参数设置标题,filetypes参数设置文件类型
课程教程:python怎么打开文件对话框上一篇:python怎么打开编辑器
下一篇:没有了