Unicode strings in tornado web app

前端 未结 1 1676
夕颜
夕颜 2021-01-23 16:34

How can I use unicode strings in tornado views or templates?
I insert in template

1条回答
  •  深忆病人
    2021-01-23 17:23

    Once you have your unicode string ready, the request should end

    self.render("template.html", aString=aUnicodeString)
    

    This renders the file "template.html" setting the aString variable to aUnicodeString.

    template.html would look something like this:

    
        
            
        
        
            {{aString}}
        
    
    

    It's also possible to inline the HTML in the Tornado server.

    self.render('{{aString}}', aString=aUnicodeString)
    

    More on templates here:

    Tornado Web Server Documentation

    0 讨论(0)
提交回复
热议问题