VS Code中python输出的中文出现乱码的解决方法

在程序中加入如下代码强行控制输出格式为utf-8即可

# -*- coding: utf-8 -*-
import sys
import io
sys.stdout=io.TextIOWrapper(sys.stdout.buffer,encoding='utf8')#改变默认输出的标准编码

编码改变之前

编码改变之后

猜你喜欢

转载自blog.csdn.net/yukinoai/article/details/81624936