如何在龙卷风视图或模板中使用unicode字符串?
我插入模板
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
在视图中
# -- coding: utf-8 --输出是????
答案 0 :(得分:1)
准备好unicode字符串后,请求应该结束
self.render("template.html", aString=aUnicodeString)
这会呈现文件&#34; template.html&#34;将aString变量设置为aUnicodeString。
template.html看起来像这样:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>
{{aString}}
</body>
</html>
也可以在Tornado服务器中内联HTML。
self.render('<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /></head><body>{{aString}}</body></html>', aString=aUnicodeString)
更多关于模板的信息: