如何打開一個的unicode命名的文件(空間)從的Python腳本下內的Windows 打開一個unicode名爲xls文件?
文件名,例如:Hello עולם.xls
的Python:從腳本
對於非Unicode非間隔xls文件,os.system(filename)
效果很好。
對於非Unicode空間xls文件,os.system('"'+filename+'"')
效果很好。
但對於Unicode空間xls文件...
兩個os.system(filename)
和subprocess.call(new_filename)
給予:
UnicodeEncodeError: 'ascii' codec can't encode characters in position 12-13: ordinal not in range(128)
os.system(new_filename.encode('UTF-8'))
給出:
'Hello' is not recognized as an internal or external command, operable program or batch file.
和subprocess.call(new_filename.encode('UTF-8'))
給出:
WindowsError: [Error 2] The system cannot find the file specified
你對這個主題的知識令人印象深刻。 – 2011-04-02 11:56:16