VScode插件Code Runner运行python输出窗口出现中文乱码
VScode插件Code Runner运行python输出窗口出现中文乱码
问题描述
用Code Runner运行python程序时,输出界面中文显示乱码,如下图所示:
但是如果用终端输出,那么中文就是正常的,如下图所示:
原因
编码原因,更改为utf-8编码即可。
具体步骤如下:
解决办法
首先打开vscode的“管理”——“设置”
然后找到“扩展”
找到Run Code configuration
点击Executor Map下的 “在settings.json中编辑” 。如图所示:
找到”code-runner.executorMap“
找到”python”: “python -u“
修改python的编码格式:将python -u 改为 set PYTHONIOENCODING=utf8 && python
保存之后重新运行程序即可。
参考出处:
解决VS Code安装Code Runner插件后,输出窗口中文乱码问题(Python)
https://blog.csdn.net/ljb0077/article/details/112980095
VScode插件Code Runner运行python输出窗口出现中文乱码
http://example.com/2025/04/10/9_code_runner_utf-8/