Quantcast
Channel: okmem.com - Latest entries
Viewing all articles
Browse latest Browse all 15

另外一种if else

$
0
0

python geek

[b,a][a>=b] 取a b的较大值
[False.True]

lambda

>>> x=[1,2][1<2]>>> x
2>>> x=[1,2][1>2]>>> x
1>>>

 

>>> f=lambda x:x if x > 0 else 0>>> f(1)
1>>> f(0)
0>>> f(-1)
0>>> f(100)
100

 


Viewing all articles
Browse latest Browse all 15

Trending Articles