Python, Unicode, and the Windows console

前端 未结 13 2113
佛祖请我去吃肉
佛祖请我去吃肉 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条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-21 05:22

    Kind of related on the answer by J. F. Sebastian, but more direct.

    If you are having this problem when printing to the console/terminal, then do this:

    >set PYTHONIOENCODING=UTF-8
    

提交回复
热议问题