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
精彩评论