tkFileDialog.askdirectory()
如果目录包含非 ASCII 字符,我在 Windows 上遇到问题。
这是一个例子:
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()
在这种情况下正常工作.
我错过了什么?