Python3中的运算符

时间:2022-06-11 20:45:38

一.Python3中的运算符

强调这是Python3中的运算符

+    加法

-     减法

*     乘法

/     除法

//    整除,只要整数部分

**   幂运算

%   取余数

==  判断是否相等

!=   不等于

<     小于

<=   小于等于

and   和  且

or      或

not     非

x in y     序列y中是否含有x

x not in y     序列y中是否不含有x

is      判断两个引用是否指向同一个对象

例子:

list = ["haha","哇哈哈",15,20]
elem=15
print(elem in list)

结果:Python3中的运算符

例子:

obj1=10
obj2=10
print(obj1 is obj2)

结果:Python3中的运算符