如何从Windows下的Python脚本中打开unicode命名文件(带空格)?
文件名例如:Hello עולם.xls
对于非 unicode 非间隔 xls 文件,os.system(filename)
效果很好。
对于非 unicode 间隔的 xls 文件,os.system('"'+filename+'"')
效果很好。
但是对于 unicode 空间 xls 文件...
两者os.system(filename)
都给subprocess.call(new_filename)
:
UnicodeEncodeError:“ascii”编解码器无法对位置 12-13 中的字符进行编码:序数不在范围内(128)
os.system(new_filename.encode('UTF-8'))
给出:
'Hello' 不是内部或外部命令、可运行程序或批处理文件。
并subprocess.call(new_filename.encode('UTF-8'))
给出:
WindowsError: [错误 2] 系统找不到指定的文件