Writing unicode strings via sys.stdout in Python

后端 未结 5 867
悲哀的现实
悲哀的现实 2020-11-30 02:22

Assume for a moment that one cannot use print (and thus enjoy the benefit of automatic encoding detection). So that leaves us with sys.stdout. Howe

5条回答
  •  [愿得一人]
    2020-11-30 02:52

    There is an optional environment variable "PYTHONIOENCODING" which may be set to a desired default encoding. It would be one way of grabbing the user-desired encoding in a way consistent with all of Python. It is buried in the Python manual here.

提交回复
热议问题