python---常用运算符

                                         常用运算符

- 算术运算符: +(加号), -(减号), *(乘号), **(幂),  /(除号),  %(取余),  //(根号)

```

**** /:
# python2:

>>> 5/2
2
>>> 100/300
0
>>> 5/2.0
2.5
>>> 100/300.0
0.3333333333333333


>>> from __future__ import division (由python2转换成python3)
>>> 5/2
2.5
>>> 100/300
0.3333333333333333

# python3:
>>> 5/2
2.5
>>> 100/300
0.3333333333333333


```


# 赋值运算符:=, +=, -=, /=, *=, %=

关系运算符:>,>=,<,<=,!=,==

逻辑运算符:逻辑与and,逻辑或or,逻辑非not

猜你喜欢

转载自blog.csdn.net/suifengOc/article/details/81507625