1

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()この場合に正しく機能させるために変更する追加のパラメーターや設定が見つかりません。 .

私は何が欠けていますか?

4

1 に答える 1

0

WindowsでtkFileDialogを使用して時間を過ごし、最終的にこれを使用してファイル名の解析に関する問題を解決しました:

import Tkinter
Tkinter.wantobjects = 0

askopenfiles()私はand notを使用していたことに注意してaskdirectory()ください。しかし、おそらくあなたの状況ではうまくいくでしょう。

于 2013-07-17T00:32:44.390 に答える