Python 整数类型常用成员函数详解
- abs(): 返回整数的绝对值。
- bit_length(): 返回整数的二进制表示的位数。
- conjugate(): 返回整数的共轭复数。
- from_bytes(bytes, byteorder, *, signed=False): 根据字节数组和字节顺序返回整数。
- to_bytes(length, byteorder, *, signed=False): 将整数转换为指定字节长度的字节数组。
- denominator: 整数的分母,用于有理数的表示。
- numerator: 整数的分子,用于有理数的表示。
- real: 整数的实部,用于复数的表示。
- imag: 整数的虚部,用于复数的表示。
- bit_length(): 返回整数的二进制表示的位数。
- to_bytes(length, byteorder, *, signed=False): 将整数转换为指定字节长度的字节数组。
- from_bytes(bytes, byteorder, *, signed=False): 根据字节数组和字节顺序返回整数。
- add(self, other): 实现整数的加法运算。
- sub(self, other): 实现整数的减法运算。
- mul(self, other): 实现整数的乘法运算。
- floordiv(self, other): 实现整数的整除运算。
- mod(self, other): 实现整数的取模运算。
- divmod(self, other): 实现整数的除法与取模运算。
- pow(self, exponent[, modulus]): 实现整数的幂运算。
- lshift(self, other): 实现整数的左移运算。
- rshift(self, other): 实现整数的右移运算。
- and(self, other): 实现整数的按位与运算。
- or(self, other): 实现整数的按位或运算。
- xor(self, other): 实现整数的按位异或运算。
- invert(self): 实现整数的按位取反运算。
原文地址: https://www.cveoy.top/t/topic/pkTJ 著作权归作者所有。请勿转载和采集!