推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
Anhedonia
V2EX  ›  Python

VSC 写 Python 出现了编码问题

  •  
  •   Anhedonia · Feb 26, 2017 · 3996 views
    This topic created in 3376 days ago, the information mentioned may be changed or developed.

    用 coderunner 插件运行 Python 文件

    UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-3: ordinal not in range(128) 报错提示这个

    问题是我已经在文件最上面加了

    -- coding: utf-8 --

    而且 vsc 的设置里 files.encoding": "utf8", 也设置好了

    这是为什么呢?

    6 replies    2017-02-27 09:33:44 +08:00
    formulahendry
        1
    formulahendry  
       Feb 26, 2017 via Android   ❤️ 1
    你好,我是插件作者。你 py 文件内容是啥,里面有中文?可以试试这里面的三种解决方案: https://github.com/formulahendry/vscode-code-runner/issues/25
    Anhedonia
        2
    Anhedonia  
    OP
       Feb 26, 2017
    @formulahendry 好啦好啦!!谢谢谢谢!!!!顺便一提 你的插件好棒的!
    formulahendry
        3
    formulahendry  
       Feb 26, 2017 via Android
    @Anhedonia 😀
    kevin100702
        4
    kevin100702  
       Feb 26, 2017 via Android
    Import Io
    Io.set …………
    原谅我不会手机打代码
    WildCat
        5
    WildCat  
       Feb 26, 2017 via iPhone
    @formulahendry 全球第一工单论坛 😂
    suixn
        6
    suixn  
       Feb 27, 2017
    ···
    import io
    sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf8')
    ···
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3280 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 12:13 · PVG 20:13 · LAX 05:13 · JFK 08:13
    ♥ Do have faith in what you're doing.