day2杂---三元运算 is

三元运算
>>> a,b,c = 1,3,5
>>> d = a if a>b else c
>>> d
5
>>> d = a if a<b else c
>>> d
1
 
>>> name
>>> type(name)
<class 'str'>
>>> type(name) == str
True
>>> type(name) is int
False
>>> type(name) is str
True
 
>>> 3 !=2
True
>>> 
>>> 
>>> a,b = 1,2
>>> a>1 and b>2
False
>>> a>1 or b>2
False
>>> a>1 or b>a
True
 
posted on 2016-08-04 00:02  DCC_python  阅读(134)  评论(0编辑  收藏  举报