[英]python - web.py render html without using templates
import web
class index:
def GET(self):
i = web.input(age=None)
return "You are " + i.age
if __name__ == "__main__":
app = web.application(urls, globals())
app.run()
This is my code. 这是我的代码。 I'm testing something.
我正在测试。
It isn't rendering the html. 它不呈现html。 For example, If I return i.name by itself, and the age (i.age) parameter =
<b>25</b>
, it will show 5 as bolded and it renders it nicely. 例如,如果我自己返回i.name,并且age(i.age)参数=
<b>25</b>
,它将以粗体显示5并很好地呈现它。 However, if I return return "You are " + age
, the html will not render and it will just show as Hi <b>25</b>
但是,如果我返回
return "You are " + age
,则html不会渲染,而只会显示为Hi <b>25</b>
您可以使用return "<html>Your are" + i.age + "</html>"
因为也会考虑用户输入的任何标记。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.