开发者

How to get the first element of an array Python, from HTML

I have an array called list, for example

list = [0,1,2,3]

in the HTML when i do this

<bo开发者_运维百科dy>
{{ list }}
</body>

the output will be [0,1,2]

what i want is

{{ list[0] }}

but this statement is giving me error, how i can just print the first element


If you're using Django, try this: {{ list.0 }} or for slicing: {{ list|slice:":1" }}

Docs: http://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs#slice

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜