Any way to add a new line from a string with the '\n' character in flask?

前端 未结 5 632
一整个雨季
一整个雨季 2020-12-24 07:58

I was playing around with flask when I came across an odd problem with the \'\\n\' character. it dosen\'t seem to have an effect in my browser, I tried putting
in the

5条回答
  •  失恋的感觉
    2020-12-24 08:03

    Disable auto escaping

    your_arr = your_arr.replace('\n', '
    ') {% for your_text in your_arr %} {{ (your_text | safe) }} {% endfor %}

    Note: With | safe Jinja2 will print symbols as they are in your variable, that means that it won't translate "dangerous" symbols into html entities (that Jinja2 does by default to escape "dangerous" ones). Use this option if you trust variable's content... Read more

提交回复
热议问题