python - How to print the \n character in Jinja2 -
i have following string in python: thestring = "123\n456"
in jinja2 template, use {{thestring}}
, output is:
123
456
the way can jinja2 print exact representation 123\n456
(including \n
) escaping thestring = "123\\n456"
.
is there other way can done directly in template?
i'll answer own, maybe helps has same question.
this works: {{thestring.encode('string_escape')}}
Comments
Post a Comment