Solution to Chinese garbled output of python code in VSCode

Preface

Recently, when vs codeI execute pythona script in it, only Chinese characters are printed, and the characters are garbled.

content

First check whether the encoding set setting in the lower right corner is correct.

Check whether the encoding set setting in the lower right corner is correct:
Insert image description here

If not, utf-8click Modify.

If it still doesn’t work, do the following:

Modify user settings

Path: File—> preferences—>settings

Search: code-runner.executorMap, then clickedit in settings.json
Insert image description here

Add to:

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

Insert image description here


That's the end.

Reference address:
https://blog.csdn.net/zhangfeng0881/article/details/112632018

Guess you like

Origin blog.csdn.net/u013066244/article/details/132004544