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

import 一个网页检查模块的时候报错:SyntaxError: 'gbk' codec can't decode bytes in position 28-29: illegal multibyte sequence。

  •  
  •   shyrock · 2014-05-22 14:53:40 +08:00 · 7189 次点击
    这是一个创建于 3646 天前的主题,其中的信息可能已经有所发展或是发生改变。
    被引入模块和主模块都是cp936编码的,换成utf-8也不行,有大大知道怎么解决吗?
    2 条回复    2014-05-22 15:29:07 +08:00
    shyrock
        1
    shyrock  
    OP
       2014-05-22 15:10:22 +08:00
    补充:网页检查代码中有中文。如果换成utf-8,报错:UnicodeDecodeError: 'ascii' codec can't decode byte 0xe7 in position 0: ordinal not in range(128)
    shyrock
        2
    shyrock  
    OP
       2014-05-22 15:29:07 +08:00
    问题关闭,是我愚蠢的忘了在字符串前加u。。。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5613 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 07:56 · PVG 15:56 · LAX 00:56 · JFK 03:56
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.