V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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
omg21
V2EX  ›  Python

(四在农家•美丽乡村),这个点应该怎么处理

  •  
  •   omg21 · 2017-03-15 23:18:53 +08:00 · 2054 次点击
    这是一个创建于 2600 天前的主题,其中的信息可能已经有所发展或是发生改变。

    在网上抓取的新闻,有时候会遇到这样的点,文字编码已经转换过了,但还是会报错 'gbk' codec can't encode character '\u2022' in position 20

    不知道该如何处理这个点。系统 是 python3.4+sublime

    4 条回复    2017-03-16 12:33:50 +08:00
    bxb100
        1
    bxb100  
       2017-03-15 23:37:00 +08:00 via Android
    转成 UTF-8 应该能解决啊
    PythonAnswer
        2
    PythonAnswer  
       2017-03-16 02:22:57 +08:00 via Android
    不 print 出来 是没事的。你的 windows stdout 不是 utf8 。
    nyanyh
        3
    nyanyh  
       2017-03-16 07:14:23 +08:00
    执行 py 脚本前先在 cmd 执行一下 chcp 65001
    backing
        4
    backing  
       2017-03-16 12:33:50 +08:00
    可能这个字符 gbk 没有收录,可以考虑用 GB18030
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1113 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 18:07 · PVG 02:07 · LAX 11:07 · JFK 14:07
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.