python3.6以后 print无法输出中文的解决方法

python3.6以后 编码方式已经是unicode,但是print输出中文仍出错。

查找资料说是print限制问题,

解决方法:

  添加以下代码

  import io
  import sys
  sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf-8')

posted @ 2022-05-12 15:29  MELANCHOLYS  阅读(541)  评论(0编辑  收藏  举报