推荐学习书目
› 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 · Jul 15, 2014 · 4148 views
    This topic created in 4474 days ago, the information mentioned may be changed or developed.
    UnicodeDecodeError: 'utf8' codec can't decode byte 0xb0 in position 1: invalid start byte
    4 replies  •  2014-07-15 17:46:44 +08:00
    wxq552
        1
    wxq552  
    OP
       Jul 15, 2014
    这是我的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  
       Jul 15, 2014
    声明的是 utf-8,但实际保存的 py 文件编码不是 utf-8的,检查你的编辑器
    tonyluj
        3
    tonyluj  
       Jul 15, 2014
    用notepad++,utf-8编码
    editor用vim吧,早用早幸福
    BiggerLonger
        4
    BiggerLonger  
       Jul 15, 2014
    'Hello world'.decode('utf-8') 试试
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1160 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 23:26 · PVG 07:26 · LAX 16:26 · JFK 19:26
    ♥ Do have faith in what you're doing.