方式一
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