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
invite
V2EX  ›  Python

Python 编码疑问?

  •  
  •   invite · 2015-01-19 19:50:59 +08:00 · 2036 次点击
    这是一个创建于 3377 天前的主题,其中的信息可能已经有所发展或是发生改变。
    情况是这样的:
    1. 用urllib2获取一个web页面, 页面是UTF-8的编码.
    2. 用BeautifulSoup解析

    结果报错: 'gbk' codec can't encode character....

    这个 gbk 是什么时候出现的?

    环境: Windows XP / Python 2.7
    2 条回复    2015-01-19 20:50:07 +08:00
    aeshfawre
        1
    aeshfawre  
       2015-01-19 20:24:29 +08:00
    显示的窗口是gbk的, 你不显示到窗口上,就应该不抱错了
    invite
        2
    invite  
    OP
       2015-01-19 20:50:07 +08:00
    @aeshfawre 原来这样,多谢。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3327 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 11:55 · PVG 19:55 · LAX 04:55 · JFK 07:55
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.