![](/img/trans.png)
[英]Python - Get Path of Selected File in Current Windows Explorer
[英]Use Windows explorer to get the path to a file in python
我將如何1.訪問Windows資源管理器2.使用它來獲取文件的路徑。 例如,當我單擊“打開”時,它將所選文件的地址粘貼到輸入框中
如果有幫助,我正在使用tkinter。 提前致謝。
使用諸如from tkinter import filedialog
tkinter.filedialog
的語句from tkinter import filedialog
(3.x)或import FileDialog as filedialog
(2.x)。 這個模塊沒有在CPython文檔中正確記錄,也沒有在我所知的其他地方正確記錄,因此請閱讀代碼以確定您要使用哪種ask...
方法。 在3.x中,代碼為Lib/tkinter/filedialog.py
。 在2.x中, Lib/libtk/FileDialog.py
。
編輯:從您說的話,您可能想要askopenfilename
或askopenfilenames
。 我相信這些返回名稱無需打開文件。 沒有name
的功能實際上會打開文件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.