def foo(arg):
return arg if arg else None
python开发中的三目运算
原创
©著作权归作者所有:来自51CTO博客作者水痕01的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
python三目运算符的用法 python有没有三目运算
1.前言学习过编程语言的话一定知道一个称为"三目运算符"(三元表达式)的东西,一般来说我们可以把它看成是一个简单的"if-else"语句。下面是在java中的三目表达式(其实在大多数的语言中都是这样的): 单目运算符: ~3(位运算符取反码) 双目运算符:3 + 4 三目运算符: 格式:比较(关系)表达式 ?表达式1 :表达式2; 比较表达式:结果
python三目运算符的用法 python有没有三元运算符 python结果输出在哪里看 运算符 Python