Python, Unicode, and the Windows console

前端 未结 13 2151
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-21 04:38

When I try to print a Unicode string in a Windows console, I get a UnicodeEncodeError: \'charmap\' codec can\'t encode character .... error. I assume this is b

13条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-21 05:16

    Python 3.6 windows7: There is several way to launch a python you could use the python console (which has a python logo on it) or the windows console (it's written cmd.exe on it).

    I could not print utf8 characters in the windows console. Printing utf-8 characters throw me this error:

    OSError: [winError 87] The paraneter is incorrect 
    Exception ignored in: (_io-TextIOwrapper name='(stdout)' mode='w' ' encoding='utf8') 
    OSError: [WinError 87] The parameter is incorrect 
    

    After trying and failing to understand the answer above I discovered it was only a setting problem. Right click on the top of the cmd console windows, on the tab font chose lucida console.

提交回复
热议问题