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

前端 未结 5 599
一整个雨季
一整个雨季 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:09

    In case someone end up here like me, and doesn't want to use {% autoescape false %}, for safety reasons, nor braking up the text which might be inconvenient in some cases, I found a good alternative here:

    from flask import Markup
    value = Markup('First line.
    Second line.
    ')

    and then in the jinja template:

    {{ value }}
    

提交回复
热议问题