开发者

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

开发者 https://www.devze.com 2023-02-15 02:24 出处:网络
I have an array called list, for example list = [0,1,2,3] in the HTML when i do this <bo开发者_运维百科dy>

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

精彩评论

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