推荐学习书目
› 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 · 4323 views
    This topic created in 3537 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
    formulahendry
    Feb 26, 2017 via Android❤️1
    1
    你好,我是插件作者。你 py 文件内容是啥,里面有中文?可以试试这里面的三种解决方案: https://github.com/formulahendry/vscode-code-runner/issues/25
    Anhedonia
    Anhedonia
    OP
    Feb 26, 2017
    2
    @formulahendry 好啦好啦!!谢谢谢谢!!!!顺便一提 你的插件好棒的!
    formulahendry
    formulahendry
    Feb 26, 2017 via Android
    3
    @Anhedonia 😀
    kevin100702
    kevin100702
    Feb 26, 2017 via Android
    4
    Import Io
    Io.set …………
    原谅我不会手机打代码
    WildCat
    WildCat
    Feb 26, 2017 via iPhone
    5
    @formulahendry 全球第一工单论坛 😂
    suixn
    suixn
    Feb 27, 2017
    6
    ···
    import io
    sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf8')
    ···
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1306 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 21:01 · PVG 05:01 · LAX 13:01 · JFK 16:01
    ♥ Do have faith in what you're doing.