Python tkFileDialog.askdirectory()管理unicode目录

Python tkFileDialog.askdirectory()管理unicode目录,python,tkinter,Python,Tkinter,如果目录包含非ASCII字符,则在Windows上使用tkFileDialog.askdirectory()时出现问题 下面是一个例子: import tkFileDialog # Open folder C:\notused\weekly\1\Music\岩崎 琢 # (But while the dialog is open, the dialog itself shows the name mangled # as "C:\notused\weekly\1\Music\?? ?") o_r

如果目录包含非ASCII字符,则在Windows上使用
tkFileDialog.askdirectory()
时出现问题

下面是一个例子:

import tkFileDialog
# Open folder C:\notused\weekly\1\Music\岩崎 琢
# (But while the dialog is open, the dialog itself shows the name mangled
# as "C:\notused\weekly\1\Music\?? ?")
o_result = tkFileDialog.askdirectory()
# Return result is unicode, which is correct..
print type(o_result)
# ...but the result string has the non-English characters mangled.
print o_result
# And it's not just the display, they seem to be actually mangled.
print ord(o_result[-1])
# The ordinal value of the final character is the same as the question-mark
print ord('?')
我注意到对话框本身在我触摸它之前就显示了损坏的字符串(这告诉我这不是我的处理错误),但我找不到任何其他参数或设置可以更改以使
askdirectory()
在这种情况下正常工作


我遗漏了什么?

我曾在Windows下使用tkFileDialog,最终通过以下方式解决了文件名解析问题:

import Tkinter
Tkinter.wantobjects = 0

请注意,我使用的是
askopenfiles()
而不是
askdirectory()
,但它可能适用于您的情况。

在快速测试期间,它看起来不起作用,但我会在有更多时间后重试。