一、int内部功能解释
1. bit_length:返回数字占用的二进制最小位数
def bit_length(self): # real signature unknown; restored from __doc__ """ int.bit_length() -> int Number of bits necessary to represent self in binary. >>> bin(37) ‘0b100101‘ >>> (37).bit_length() 6 """ return 0 eg. >>> num=25 >>> num.bit_length() >>> 5 #数字25使用二进制表示为: 000011001,占用最小位数为5(11001)
2. conjugate:返回复数的共轭复数
a+bi(a,b均为实数)的数称为复数,其中a称为实部,b称为虚部,i称为虚数单位
def conjugate(self, *args, **kwargs): # real signature unknown """ Returns self, the complex conjugate of any int. """ pass eg. >>> num=1.2+2.3j >>> num.real >>> 1.2 >>> num.imag >>> 2.3 >>> num.conjugate() >>> 1.2-2.3j
3. __abs__:返回绝对值
def __abs__(self, *args, **kwargs): # real signature unknown """ abs(self) """ pass eg. >>> num=-10 >>> num.__abs__() >>> 10
4. __add__:返回二者之和
def __add__(self, *args, **kwargs): # real signature unknown """ Return self+value. """ pass eg. >>> num=-10 >>> num.__add__(15) >>> 5
5. __and__:转换成二进制表示法后进行与运算
def __and__(self, *args, **kwargs): # real signature unknown """ Return self&value. """ pass eg. >>> num1=25 #--->0b11001 >>> num2=18 #--->0b10010 >>> num1.__and__(num2) # num1&num2 >>> 16 #--->0b10000
6. __bool_:返回bool值,即True or False
def __bool__(self, *args, **kwargs): # real signature unknown """ self != 0 """ pass eg. >>> a=10 >>> a.__bool__() >>> True
7.