数据运算:
+ - * / % ** // 取整数,返回商的整数部分,如9/2输出结果4,9.0/2.0输出结果4.0
>>> 9//2
4
>>> 9.0//2.0
4.0
>>> 9.0//2.5
3.0
>>> 9.0//2.4
3.0
>>> 9.0//2.3
3.0
>>> 9.0//2.2
4.0
>>> 9.0//2.1
4.0
>>>
==
!= <>
>
<
>=
<=
赋值:
=
+=
-+
*=
/=
%=
**=
//=
逻辑运算:
and
or
not
>>> a,b,c = 3,5,7
>>> print(a,b,c)
3 5 7
>>> a > 2 and c < 7
False
>>> a > 2 and c < 8 and b > 4
True
>>> if not a > 2 and c < 8 and b > 4:
... print('bbb')
...
>>> if not a < 2 and c < 8 and b > 4:print('bbb')
...
bbb
>>>
成员运算:
in
not in
身份运算:
is #判断两个标识符是不是引用自同一个对象
is not
>>> a = [1,2,3]
>>> type(a) is list
True
>>> type(a) is not list
False
>>> "abc" is "abc"
True
>>> "abc" is "abcd"
False
>>>
位运算:二进制的运算
& 按位与
| 按位或
^ 按位异或
~ 按位取反
<< 左移动
>> 右移动
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。