Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/348.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python tornado web应用程序中的Unicode字符串_Python_Tornado - Fatal编程技术网

Python tornado web应用程序中的Unicode字符串

Python tornado web应用程序中的Unicode字符串,python,tornado,Python,Tornado,如何在tornado视图或模板中使用unicode字符串? 我在模板中插入 和视图中的代码:utf-8-- # -- coding: utf-8 -- 输出是???一旦您准备好unicode字符串,请求应该结束 self.render("template.html", aString=aUnicodeString) 这将呈现文件“template.html”,将aString变量设置为aUnicodeString template.html的外观如下所示: <html>

如何在tornado视图或模板中使用unicode字符串?
我在模板中插入
和视图中的代码:utf-8-- # -- coding: utf-8 --
输出是???

一旦您准备好unicode字符串,请求应该结束

self.render("template.html", aString=aUnicodeString)
这将呈现文件“template.html”,将aString变量设置为aUnicodeString

template.html的外观如下所示:

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    </head>
    <body>
        {{aString}}
    </body>
</html>

{{aString}}
也可以在Tornado服务器中内联HTML

self.render('<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /></head><body>{{aString}}</body></html>', aString=aUnicodeString)
self.render('{{aString}}',aString=aUnicodeString)
有关模板的更多信息,请参见:


一旦您准备好unicode字符串,请求应该结束

self.render("template.html", aString=aUnicodeString)
这将呈现文件“template.html”,将aString变量设置为aUnicodeString

template.html的外观如下所示:

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    </head>
    <body>
        {{aString}}
    </body>
</html>

{{aString}}
也可以在Tornado服务器中内联HTML

self.render('<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /></head><body>{{aString}}</body></html>', aString=aUnicodeString)
self.render('{{aString}}',aString=aUnicodeString)
有关模板的更多信息,请参见:

尝试:
打印u“unicode字符串”。编码(“utf-8”)
尝试:
打印u“unicode字符串”。编码(“utf-8”)