티스토리 뷰
Template 문법에서 indexing을 사용하고자 한다면, 아래와 같이 사용하면 된다.
{% for data in lists %}
{{ data }} - {{ forloop.counter0 }}
{% endfor %}
lists 변수에 ['1', '2', '3']이 들어있다면, 1 - 0, 2 - 1, 3 - 2 값이 출력된다.
* 참고
forloop.counter - The current iteration of the loop (1-indexed)
forloop.counter0 - The current iteration of the loop (0-indexed)
forloop.revcounter - The number of iterations from the end of the loop (1-indexed)
forloop.revcounter0 - The number of iterations from the end of the loop (0-indexed)
forloop.first - True if this is the first time through the loop
forloop.last - True if this is the last time through the loop
forloop.parentloop - For nested loops, this is the loop surrounding the current one
참고 : https://docs.djangoproject.com/en/1.11/ref/templates/builtins/
'프로그래밍 > Python' 카테고리의 다른 글
| 정규표현식 전방탐색, 후방탐색 오류!?!? (0) | 2017.11.02 |
|---|---|
| [Django]UnicodeEncodeError 발생 시 해결방법 (0) | 2017.10.09 |
| [Python] collections.OrderedDict (0) | 2017.08.31 |
| [Python] krcert 최신동향 크롤링 (0) | 2017.04.19 |
| [Django] django-debug-toolbar (0) | 2017.03.15 |
- Total
- Today
- Yesterday
- AMSI
- 출처 : Do it 안드로이드 프로그래밍
- vuln
- Bisonal
- cuckoo-sandbox
- 한글악성코드
- CVE-2018-9375
- idapython
- VirusBulletin
- Kimsuky
- .wll
- CVE-2018-0798
- malware
- koodous
- 비트코인
- Servey
- Static Analysis Engine
- 악성코드
- 스피어피싱
- Flybits
- 위협정보공유
- infostealer
- 해킹메일
- MS-Office
- Cisco Talos
- us-cert
- keylogger
- Yara
- 멋쟁이사자처럼 4기
- Decoding
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |