python浏览本地文件,实现文件路径的选择
实现代码:
import tkinter as tk from tkinter import filedialog def getLocalFile(): root=tk.Tk() root.withdraw() filePath=filedialog.askopenfilename() print('文件路径:',filePath) return filePath if __name__ == '__main__': getLocalFile()
运行截图: