前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >freemaker判断空_python条件语句举例

freemaker判断空_python条件语句举例

作者头像
全栈程序员站长
发布2022-11-15 10:40:41
7600
发布2022-11-15 10:40:41
举报
文章被收录于专栏:全栈程序员必看

if…else…

<#if condition> … <#elseif condition2> … <#elseif condition3> … <#else> … </#if>

只有一个if的情况:

<#if x = 1> x is 1 </#if>

包含elseif的情况:

<#if x = 1> x is 1 <#elseif x = 2> x is 2 <#elseif x = 3> //红色位置今以前出现else if 之间有空格,这个没有,今天出现这个….. x is 3 </#if>

包含else的用法:

<#if x = 1> x is 1 <#elseif x = 2> x is 2 <#elseif x = 3> x is 3 <#elseif x = 4> x is 4 <#else> x is not 1 nor 2 nor 3 nor 4 </#if>

switch…case…default…

<#switch value> <#case refValue1> … <#break> <#case refValue2> … <#break> <#case refValueN> … <#break> <#default> … </#switch>

类似Java的普通用法:

<#switch being.size> <#case “small”> This will be processed if it is small <#break> <#case “medium”> This will be processed if it is medium <#break> <#case “large”> This will be processed if it is large <#break> <#default> This will be processed if it is neither </#switch>

不使用break的方法,即在case中进行判断:

<#switch x> <#case x = 1> 1 <#case x = 2> 2 <#default> d </#switch>

循环迭代结构

<#list sequence as item> … </#list>

迭代的同时会生成两个变量:item_index,item_has_next,意如其名:

<#assign seq = [“winter”, “spring”, “summer”, “autumn”]><#list seq as x>

也可以用break跳出循环,用法和switch语句中的方法类似。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/234250.html原文链接:https://javaforall.cn

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022年11月1日 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档