Python之Lambda表达式和if not...else用法
2017-12-06 11:18
1876 查看
# -*- coding: utf-8 -*- print("*******if...else语句*********") #if 条件为真的时候返回if前面内容,否则返回0 exp1= lambda x:x+1 if 2==1 else 0 print(exp1(2)) exp2 = lambda x:x+1 if 1==1 else 0 print(exp2(2)) print("*******if not...else语句*********") #if not 为假返回if not前面内容,否则返回0 exp3 = lambda x:x+1 if not 2==1 else 0 print(exp3(2)) exp4 = lambda x:x+1 if not 1==1 else 0 print(exp4(2))
相关文章推荐
- python 三元表达式 if for 构建List 进阶用法
- Python中defaultdict与lambda表达式用法实例小结
- python 中的map(),zip()函数以及表达式lambda用法
- 深入解析Python中的lambda表达式的用法
- Python中 if not 用法
- Python中的if、else、elif语句用法简明讲解
- 深入解析Python中的lambda表达式的用法
- python -lambda表达式的用法
- 零基础学python-11.5 真值测试与if...else...三元表达式
- Python 三元条件判断表达式(and or/if else)
- 零基础学python-11.5 真值测试与if...else...三元表达式
- python里面的几个用法,not in,c if a else b,[fun(a) for a in [...]] , a,b=b,a,'内容'.join([string array])
- PyThon---if-elif-else用法
- Python中的if、else、elif语句用法简明讲解
- python 之 lambda 表达式的基本用法
- python中lambda表达式的用法
- linux shell中 if else以及大于、小于、等于逻辑表达式介绍
- 【正则表达式】python re模块用法总结
- oracel if else 用法
- Python lambda 表达式