UnicodeEncodeError with Visual Studio Post-Build Command Line

六眼飞鱼酱① 提交于 2019-12-11 16:06:30

问题


I am trying to run a Python script from a Visual Studio C/C++ project's Post-Build Command Line. The arguments for the script contain German Umlauts, let's say Ü. The Command Line Script is

python "<path to python .py>" Ü

The Python script simply prints the first (second) argument back to the Command Line:

import sys

if __name__ == "__main__":
    print(sys.argv[1])

However, this raises an exception for the last line:

...

File "C:\Python36\lib\encoding\cp1252.py", line 19, in encode

return codecs.charmap_encode(input, self.errors, encoding_table)[0]

UnicodeEncodeError: 'charmap' codec can't encode character '\u2584' in position 0: character maps to < undefined >

How to solve this?

来源:https://stackoverflow.com/questions/47126688/unicodeencodeerror-with-visual-studio-post-build-command-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!