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')