VSCode 中文乱码

方式一

vscode 菜单栏:  文件 >> 首选项 >> 设置

搜索:

"files.autoGuessEncoding": false,

改为:

"files.autoGuessEncoding": true,

修改task.json,添加option那一段:

{
    "version": "0.1.0",
    "command": "python",
    "isShellCommand": true,
    "args": ["${file}"],
    "showOutput": "always",
    "options": {
        "env":{
            "PYTHONIOENCODING": "UTF-8"
          }
      }
}

方式二

在setting.json中设置

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

方式三

在环境变量里添加一个变量设置:PYTHONIOENCODING=utf-8

原文地址:https://www.cnblogs.com/hankleo/p/11570643.html