py代码如下:import web
render = web.template.render("templates")
urls = (
'/(.*)', 'hello',)
app = web.application(urls, globals())
class hello:
def GET(self,name):
return render.hello2(name)
if __name__ == "__main__":
app.run()html代码如下:$def with(name)
<html>
<head>
<meta http-equiv='content-type',content='text/html;charset=utf-8'>
<title>hello</title>
</head>
<body>
<h1>测试</h1>
<form action="/blog/123" method="Post">
<input type="text" name="username" value="$name">
<input type="password" name="password" value="">
<input type="submit" value="submit">
</form>
</body>
</html>
2 回答

慕函数9285021
TA贡献27条经验 获得超6个赞
python 脚本开头,一般约定加一个脚本编码的定义
如果默认的情况下,python对中文的编码方式是gbk编码,在脚本处理你的模板之后,就编程gbk的编码了,你在浏览器中使用utf-8 就会出现乱码
#! usr/env/bin python
# -*-encoding:utf-8-*-
添加回答
举报
0/150
提交
取消