Python tkFileDialog.asksaveasfile - 获取文件路径 [英] Python tkFileDialog.asksaveasfile - get file path

查看:66
本文介绍了Python tkFileDialog.asksaveasfile - 获取文件路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获取文件exportFile"的路径.

I want to get path of file "exportFile".

exportFile = tkFileDialog.asksaveasfile(mode='a')

如果我写打印导出文件",我得到:

If I write "print exportFile", I get:

<open file u'C:/Users/Desktop/Test/aaaa.txt', mode 'a' at 0x02CB6078>

但我只需要路径 - C:/Users/Desktop/Test/aaaa.txt".有什么解决办法吗?谢谢.

But I need only path - "C:/Users/Desktop/Test/aaaa.txt". Is there any solution? Thank you.

推荐答案

试试这个:

exportFile = tkFileDialog.asksaveasfile(mode='a')
exportFile.name

它会返回:

'C:/Users/Desktop/Test/aaaa.txt'

这篇关于Python tkFileDialog.asksaveasfile - 获取文件路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆