backTop

VSCode Python 中文字符输出报错 "UnicodeEncodeError: 'charmap' codec can't encode characters in position 2-5: character maps to <undefined>"

解决方法:

1.  在settings.json 中添加 

 "code-runner.executorMap": {
        "python": "set PYTHONIOENCODING=utf8 && python -u"
    }

或者

2.  在python代码中加入

import sys,io
sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf8') 

  

 
posted @ 2020-07-17 17:09  ooops!  阅读(3764)  评论(0编辑  收藏  举报