Can't print Unicode Bitcoin symbol in Python 2

后端 未结 1 606
走了就别回头了
走了就别回头了 2020-12-21 11:40

I am trying to print the Unicode Bitcoin symbol \\u2043 in Python 2. I have tried adding #-*- coding: utf-8 -*-.

$ python2 -c \'pr         


        
相关标签:
1条回答
  • 2020-12-21 12:26

    On Unix, if sys.stdout.isatty() returns True but sys.stdout.encoding is 'ANSI_X3.4-1968' (ascii) then you should configure your locale (check LANG, LC_CTYPE, LC_ALL envvars) to use non-ascii encoding if you need to print non-ascii characters.

    If sys.stdout.isatty() is false then configure PYTHONIOENCODING envvar outside your script.
    Always print Unicode, don't hardcode the character encoding of your environment inside your script.

    0 讨论(0)
提交回复
热议问题