Web.py HelloWorld與中文亂碼

1、安裝web.pyhtml

sudo easy_install web.pypython

2、代碼web

# coding=utf-8
import web

urls=(
      '/','index'
)

class index:
    def GET(self):
        web.header('Content-Type','text/html;charset=UTF-8')
        return 'Hello Word!你好!'
    
if __name__=='__main__':
    app=web.application(urls,globals())
    app.run()

3、運行app

~$ python index.py 8000
http://0.0.0.0:8000/
127.0.0.1:50398 - - [22/May/2016 11:23:07] "HTTP/1.1 GET /" - 200 OKurl

 

加上:code

        web.header('Content-Type','text/html;charset=UTF-8')htm

中文才能正常顯示。utf-8

相關文章
相關標籤/搜索