问题
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