【发布时间】:2018-05-31 22:57:31
【问题描述】:
我在 Python 中使用Flask 并想插入一个图像。
使用以下命令可以正常工作:
{{ url_for('static', filename='path/to/img.jpg') }}
但是现在我想在一个循环中插入一个图像(比如文章),并且需要一个变量的路径,比如:
{{ article.header_img_path }}
如何将变量路径插入
{{ url_for('static', filename='path/to/img.jpg') }}
命令?
类似的东西:
{{ url_for('static', filename=' {{ article.header_img_path }} ') }}
有没有更好的方法来做到这一点,还是只是我的语法损坏了?
感谢您的建议!
【问题讨论】: