python浏览本地文件,实现文件路径的选择

参考:https://www.cnblogs.com/sengzhao666/p/12748444.html

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()

运行截图:
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_21237549/article/details/121751136