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

求助,新人学习 web.py 用的是 web.py0.33 版本,python 用 2.7 版本,写了一个 HelloWorld,出现如下错误,求各位大侠指点指点。。。。

  •  
  •   wxq552 · 2014-07-15 16:51:01 +08:00 · 3346 次点击
    这是一个创建于 3583 天前的主题,其中的信息可能已经有所发展或是发生改变。
    UnicodeDecodeError: 'utf8' codec can't decode byte 0xb0 in position 1: invalid start byte
    4 条回复    2014-07-15 17:46:44 +08:00
    wxq552
        1
    wxq552  
    OP
       2014-07-15 16:52:01 +08:00
    这是我的HelloWorld代码
    #encoding: utf-8
    import web
    urls = ("/.*", "hello")
    app = web.application(urls, globals())
    class hello:
    def GET(self):
    return 'Hello, world!'
    if __name__ == "__main__":
    app.run()
    allenforrest
        2
    allenforrest  
       2014-07-15 17:09:49 +08:00
    声明的是 utf-8,但实际保存的 py 文件编码不是 utf-8的,检查你的编辑器
    tonyluj
        3
    tonyluj  
       2014-07-15 17:29:41 +08:00
    用notepad++,utf-8编码
    editor用vim吧,早用早幸福
    BiggerLonger
        4
    BiggerLonger  
       2014-07-15 17:46:44 +08:00
    'Hello world'.decode('utf-8') 试试
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5828 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 06:04 · PVG 14:04 · LAX 23:04 · JFK 02:04
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.