gpt4 book ai didi

python - 如何使用 tkFileDialog 获取文件的绝对路径?

转载 作者:太空狗 更新时间:2023-10-29 22:07:20 25 4
gpt4 key购买 nike

我正在使用:

file = tkFileDialog.askopenfile(parent=root, mode='rb', 
filetypes=[('Subrip Subtitle File','*.srt')], title='Choose a subtitle file')

获取用户指定的文件对象。

有什么办法可以从文件对象中得到这个文件的绝对路径吗?

最佳答案

file = tkFileDialog.askopenfile(parent=root,mode='rb',filetypes=[('Subrip Subtitle File','*.srt')],title='Choose a subtitle file')
abs_path = os.path.abspath(file.name)

关于python - 如何使用 tkFileDialog 获取文件的绝对路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1881202/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com