python 内置类型(一)

一、真值的定义Truth Value

除以下情形外的定义均为真值:

1.定义常量为 None 或者 False.
2.数值定义中的0,如:0, float(0.0),
3.空序列、空字典、空集合、空对象等如: (), [], {}, set(), range(0)

二、and, or, not

x and y x为真且y为真则为真,否则为假
x or y x为假且y为假则为假,否则为真
not x x为真则为假,否则为真

三、比较Comparisons

< 1 < 2
<= 2 <= 2
> 3 > 2
>= 3 >= 2
== 2 == 2
!= 3 != 2
is '123' is '123'
is not '123' is not '123'

四、加减乘除

东西太简单了,直接摘抄官网的

x + y sum of x and y
x - y difference of x and y
x * y product of x and y
x / y quotient of x and y
x // y floored quotient of x and y
x % y remainder of x / y
-x x negated
+x x unchanged
abs(x) absolute value or magnitude of x
int(x) x converted to integer
float(x) x converted to floating point
complex(re, im) a complex number with real part re, imaginary part im.im defaults to zero.
c.conjugate() conjugate of the complex number c
divmod(x, y) the pair (x // y, x % y)
pow(x, y) x to the power y
x ** y x to the power y

五、按位运算

x | y bitwise or of x and y
x ^ y bitwise exclusive or of x and y
x & y bitwise and of x and y
x << n x shifted left by n bits
x >> n x shifted right by n bits
~x the bits of x inverted

你可能感兴趣的:(python 内置类型(一))