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

请问为什么抓取数据时字符会a变b,双引号变#号等

  •  
  •   csx163 · Jul 29, 2013 · 4553 views
    This topic created in 4671 days ago, the information mentioned may be changed or developed.
    在使用urllib2抓取数据时, 对方是gbk编码先转编码

    str=decode('gb18030').encode('utf8')
    MySQLdb.escape_string(str)

    其他无任何处理了

    最后用utf8存入了mysql

    但每几千条会碰到一个字符错误,不是a变成b,就是"号变为#号,由于是xml,就变得根本无法解析

    请问问题出在哪里呢?
    3 replies    1970-01-01 08:00:00 +08:00
    yautou
        1
    yautou  
       Jul 29, 2013
    我以前是傻傻的正则替换,然后忘了现在正确的解决办法=。=
    jerntseedee
        2
    jerntseedee  
       Aug 21, 2013
    你好,我在一篇关于portal认证的帖子中看到了你的回复。想请问你对创业有没有兴趣?我的英雄帖,不妨关注下哈:http://www.v2ex.com/t/79537
    GordianZ
        3
    GordianZ  
       Aug 21, 2013
    @jerntseedee 请不要劫持主题,警告一次。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1186 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 41ms · UTC 23:32 · PVG 07:32 · LAX 16:32 · JFK 19:32
    ♥ Do have faith in what you're doing.