template.py-for以及if的使用
来源:互联网 发布:java 中map的put用法 编辑:程序博客网 时间:2024/05/18 15:26
<ul> <h1>reversed表示该for循环反向取值 在模板文件中 break continue无法使用</h1> {# reversed表示该for循环反向取值 在模板文件中 break continue无法使用 #} {% for book in book_list reversed %} {# 每执行一次循环,会添加一个li标签 #} <li>{{ book }}</li> {% endfor %}</ul> <h1>forloop.conter的使用</h1>{# <ul>#}{# <h1>forloop.conter的使用</h1>#} {# 在模版文件中break continue无法使用 #} {# forloop.conter for循环执行到第几次 从1开始#} {# forloop.conter0 for循环执行到第几次 从0开始#} {# forloop.revconter0 for循环执行到第几次 从0开始;不加0从1开始#}{##}{# {% for book in book_lis %}#} {# 判断for循环是否是第一次循环 #}{# {% if forloop.first %}#}{# <h1>{{ forloop.conter0 }}.{{ book }}</h1>#}{# {% endif %}#}{# {% endfor %}#}{# </ul>#} <ul> <h1>forloop.revcounter0的使用</h1> {# forloop.counter for循环执行到第几次了,从1开始 counter0 从0开始 #} {# forloop.revcounter 反向索引从1开始 ,forloop.revcounter0 从0开始 #} {% for book in book_list %} {# 每执行一次循环,会添加一个li标签 #} <li>{{ forloop.revcounter0 }}.{{ book }}</li> {% endfor %} </ul> <ul> <h1>判断语句与for循环的结合使用</h1> {% for book in book_list %} {# 判断for循环是否是第一次循环 #} {% if forloop.first %} <h1>for循环开始了</h1> {% endif %} <li>{{ book }}</li> {# 如果for循环执行到最后一次,条件成立 #} {% if forloop.last %} <h1>for结束了</h1> {% endif %} {% endfor %} </ul><ul> {% for number in numbers %} <li>{{ number }}</li> {# 当列表为空,会执行empty后的代码 #} {% empty %} <h3>numbers中没有数据</h3> {% endfor %}</ul>
阅读全文
0 0
- template.py-for以及if的使用
- Octave教程五:控制语句if/while/for以及函数的定义和使用
- iOS基础知识:if 语句以及if语句的使用注意事项
- Shell .sh,for, if, 变量的使用
- 使用web.py的template出现 EOF in multi-line statement
- Python的if判断以及for循环、range()函数
- Py中的条件判断,if语句总结以及常见错误
- 微信小程序判断wx:if wx:for template
- 【条件渲染】关于在<template>上使用v-if分类的理解
- web.py的使用
- __init__.py的使用
- DB2触发器的创建以及IF ELSEIF的使用
- jstl标签for循环和if判断的使用
- Python中for循环和if判断语句的使用
- for循环与if判断的嵌套使用
- 使用for、if语句添加用户的一个shell脚本
- bashshell if read for while until 的使用
- 使用Repeater的Template
- vue子调父 $emit props及<slot>的综合使用
- 手机验证码
- export,import ,export default
- RedHat 7.3 命令操作方式
- 3324 顺序表应用1:多余元素删除之移位算法
- template.py-for以及if的使用
- TCP连接和断开过程详解
- ELK 实现 Java 分布式系统日志分析架构
- JAVA-笔记2
- ZXing生成二维码和带logo的二维码
- 关于STM32F4 USART6 1200波特率乱码问题
- Python 习题
- c语言中的static
- js 中 添加动态参数