This article brings you a brief introduction to operators in python3. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
Expression
Operator
Operator classification:
Arithmetic operators
Relational operators
Assignment operators
Logical operators
Bit operations
Member operations
Identity operators
Arithmetic operators
Comparison operator
- Compares two variables or values
- The result of the operation is a Boolean value , that is, false/true
- == equal sign != not equal to > greater than < less than >= greater than or equal to <= less than or equal to
Assignment operator
- =, assignment
- =, is an abbreviation (a =b is equivalent to a=a b), the same principle Also: -=
= /= //= %= *=
##Logical operator
for Boolean Values are operated on and logical AND or logical OR not logical NOT Operation rules:
and is regarded as multiplication, or is regarded as addition True is regarded as 1, False is regarded as 0 The logical operation can be converted into integer mathematical operation The final result is 0, otherwise it is False For True
Short-circuit problem of logical operations
Logical operation expressions are calculated according to the order of operations. Once If the future value of the entire formula can be determined, the calculation will no longer be performed and the
#member operator
in is used. Test whether a variable is a member of another variable not in identity operator
is is used to detect whether two variables are the same variable not is Operator priority issue
Brackets have the highest priority Priority table** 指数 (最高优先级)
~ + - 按位翻转, 一元加号和减号 (最后两个的方法名为 +@ 和 -@)
* / % // 乘,除,取模和取整除
+ - 加法减法
>> << 右移,左移运算符
& 位 'AND'
^ | 位运算符
<= < > >= 比较运算符
<> == != 等于运算符
= %= /= //= -= += *= **= 赋值运算符
is is not 身份运算符
in not in 成员运算符
not or and 逻辑运算符
Copy after login
Related recommendations:
Basic introduction to operators in php
python operator-identity operator for objects (example analysis)
The above is the detailed content of A brief introduction to operators in python3. For more information, please follow other related articles on the PHP Chinese website!