推荐学习书目
› 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
kidlfy
V2EX  ›  Python

python2 编码设置 sys

  •  
  •   kidlfy · Sep 14, 2018 · 2127 views
    This topic created in 2935 days ago, the information mentioned may be changed or developed.

    coding: utf-8

    import sys reload(sys) sys.setdefaultencoding('utf8')

    为什么 setdefaultencoding 飘黄,没有这个方法

    5 replies  •  2018-09-14 16:40:06 +08:00
    mcoo1997
        1
    mcoo1997  
       Sep 14, 2018 via Android
    pycharm 的提示么 能运行就别管
    holajamc
        2
    holajamc  
       Sep 14, 2018
    虽然在 python2 中这可以解决部分编码问题,但十分不建议这样操作)
    kidlfy
        3
    kidlfy  
    OP
       Sep 14, 2018
    @mcoo1997 但是没有用啊,还是报编码错误
    kidlfy
        4
    kidlfy  
    OP
       Sep 14, 2018
    @holajamc 虽然知道但是在 mysql 导成 excel 时,save 的时候总是报编码错误,mysql 导出的数据中含有中文,设置了 charset=utf8 也没用
    mcoo1997
        5
    mcoo1997  
       Sep 14, 2018 via Android
    @kidlfy csv 有 unicode-csv 你看看 xls 有没有类似的库
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   5427 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 45ms · UTC 02:23 · PVG 10:23 · LAX 19:23 · JFK 22:23
    ♥ Do have faith in what you're doing.