【问题标题】:Use Windows explorer to get the path to a file in python使用 Windows 资源管理器在 python 中获取文件的路径
【发布时间】:2017-07-07 09:00:51
【问题描述】:

我会怎么做 1.访问windows资源管理器 2. 使用它来获取文件的路径。例如,当我单击“打开”时,它会将所选文件的地址粘贴到输入框中

如果有帮助的话,我正在使用 tkinter。 提前致谢。

【问题讨论】:

标签: python windows tkinter explorer


【解决方案1】:

使用from tkinter import filedialog (3.x) 或import FileDialog as filedialog (2.x) 等语句导入tkinter.filedialog。该模块在 CPython 文档中以及我所知道的任何其他地方都没有正确记录,因此请阅读代码以确定您要使用哪个 ask... 方法。在 3.x 中,代码为 Lib/tkinter/filedialog.py。在 2.x 中,Lib/libtk/FileDialog.py

编辑:根据您所说,您可能想要askopenfilenameaskopenfilenames。我相信这些返回名称无需打开文件。没有name 的函数实际上是打开文件的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-09-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-30
    相关资源
    最近更新 更多