"" type="hidden"/>

VSCode Python 中文字符输出报错 "UnicodeEncodeError: 'charmap' codec can't encode characters in position 2-5: character maps to "


解决方法:

1.  在settings.json 中添加 

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

或者

2.  在python代码中加入

import sys,io
sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf8') 

  

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM