尝试使用win32访问具有俄语unicode字符的文件时文件.CreateFile(),我得到:
Traceback (most recent call last):
File "test-utf8.py", line 36, in <module>
None )
pywintypes.error: (123, 'CreateFile', 'The filename, directory name, or volume l
abel syntax is incorrect.')
这是密码。使用Python I。我验证可以用常规Python“open”打开它:
^{pr2}$
解决方案是使用
CreateFileW
而不是CreateFile
:fileH = win32file.CreateFileW
具有讽刺意味的是,documentation for CreateFile表示它支持PyUnicode字符串,但底层Windows函数不支持,除非使用CreateFileW。CreateFileW支持unicode的宽字符。在
感谢这篇讨论CreateFile的C版本的帖子:How do I open a file named ?.txt with CreateFile() API function?
相关问题 更多 >
编程相关推荐