如何从web2py中的列表中打印出数据

时间:2014-07-26 20:19:51

标签: web2py-modules

在如下所示的代码中,我将数据转储到列表中,如下所示:

def foo():
    list1=[It’s possible Arianne could appear in future seasons, but as Kotaku notes,   the official character bio of Trystane describes him as the heir to Dorne, while Ariane’s love interest, Aerys Oakheart, has also not been cast. The exclusion comes as a surprise to fans, not just because Arianne is a major player in the fantasy novels’ numerous plot twists, but also because she was a strong, complex female character in a fictional universe that doesn’t have too many of those.]
    return list1

在视图中使用html:

{{extend 'layout.html'}}
<h1>{{=list1}}</h1>

如何将每个句子打印成子弹点?

1 个答案:

答案 0 :(得分:0)

控制器:

def foo(): list1=["It's possible Arianne could appear in future seasons, but as Kotaku notes, the official character bio of Trystane describes him as the heir to Dorne, while Ariane’s love interest, Aerys Oakheart, has also not been cast.", "The exclusion comes as a surprise to fans, not just because Arianne is a major player in the fantasy novels’ numerous plot twists, but also because she was a strong, complex female character in a fictional universe that doesn’t have too many of those."] return dict(list1=list1)

查看:

{{extend 'layout.html'}}

<ul>

{{for row in list1:}}

<li>{{=row}} </li>

{{pass}}

</ul>

视图遍历列表,并为控制器传递的每个项目创建一个“li”标记。