1

以下に示すようなコードでは、次のようにリストにダンプされるデータがあります。

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>

各文を箇条書きとして印刷するにはどうすればよいですか?

4

1 に答える 1

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>

ビューはリストを繰り返し処理し、コントローラーから渡された各項目ごとに 1 つの "li" タグを作成します。

于 2014-11-07T17:20:35.607 に答える