防止瓶子在循环中打印新的生产线(Preventing flask from printing new line in a loop)

编程入门 行业动态 更新时间:2024-10-22 23:48:51
防止瓶子在循环中打印新的生产线(Preventing flask from printing new line in a loop)

我正试图在Flash中使用循环产生表格标题,但每次之后都会换行:

{% extends "layout.html" %} {% block title %} Portfolio overview {% endblock %} {% block main %} {% for variable in variables -%} {% for key, value in variable.items() -%} <table> <thead><th>{{ key }}</th></thead> {% endfor -%} {% for key, value in variable.items() -%} <tbody> <td>{{ value }}</td> </tbody> {% endfor -%} {%- endfor -%} </table> <h2>Cash available (US$): {{ cash }}</h2> <h2>Total portfolio value (US$): {{ wealth }}</h2> {% endblock %}

结果

不过,我想获得这个期望的结果

I am trying to produce table headings using loop in flash but I get new lines after each:

{% extends "layout.html" %} {% block title %} Portfolio overview {% endblock %} {% block main %} {% for variable in variables -%} {% for key, value in variable.items() -%} <table> <thead><th>{{ key }}</th></thead> {% endfor -%} {% for key, value in variable.items() -%} <tbody> <td>{{ value }}</td> </tbody> {% endfor -%} {%- endfor -%} </table> <h2>Cash available (US$): {{ cash }}</h2> <h2>Total portfolio value (US$): {{ wealth }}</h2> {% endblock %}

Result

However, I would like to get this Desired result

最满意答案

给这一个镜头;

{% extends "layout.html" %} {% block title %} Portfolio overview {% endblock %} {% block main %} <table> {% for variable in variables %} <thead> {% for key, value in variable.items() %} <th>{{ key }}</th> {% endfor %} </thead> <tbody> {% for key, value in variable.items() %} <td>{{ value }}</td> {% endfor %} </tbody> {% endfor %} </table> <h2>Cash available (US$): {{ cash }}</h2> <h2>Total portfolio value (US$): {{ wealth }}</h2> {% endblock %}

我只是修正了for循环的位置。

Give this a shot;

{% extends "layout.html" %} {% block title %} Portfolio overview {% endblock %} {% block main %} <table> {% for variable in variables %} <thead> {% for key, value in variable.items() %} <th>{{ key }}</th> {% endfor %} </thead> <tbody> {% for key, value in variable.items() %} <td>{{ value }}</td> {% endfor %} </tbody> {% endfor %} </table> <h2>Cash available (US$): {{ cash }}</h2> <h2>Total portfolio value (US$): {{ wealth }}</h2> {% endblock %}

I just fixed up the placement of your for loops.

更多推荐

本文发布于:2023-08-07 05:06:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1461244.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:瓶子   生产线   Preventing   flask   line

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!