一、安装web.py
sudo easy_install web.py
二、代码
# 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()
三、运行
~$ 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 OK
加上:
web.header('Content-Type','text/html;charset=UTF-8')
中文才能正常显示。