1.2python基础_数字类型_数字(Number)类型
程序员文章站
2022-06-17 08:20:40
一、整型(int型、整数) 整型 等价于C中的有符号长整型(long) 与系统的最大整型一致(如32位机器上的整型是32位,64位机器上的整型是64位), 可以表示的整数范围在[-sys.maxint-1, sys.maxint]之间。整型字面值的表示方法有3种: 十进制(常用)、八进制(以数字“0 ......
一、整型(int型、整数)
整型 等价于c中的有符号长整型(long)
与系统的最大整型一致(如32位机器上的整型是32位,64位机器上的整型是64位),
可以表示的整数范围在[-sys.maxint-1, sys.maxint]之间。整型字面值的表示方法有3种:
十进制(常用)、八进制(以数字“0”开头)和十六进制(以“0x”或“0x”开头)。
整型的标准库操作有如下
1 class int(object): 2 """ 3 int([x]) -> integer 4 int(x, base=10) -> integer 5 6 convert a number or string to an integer, or return 0 if no arguments 7 are given. if x is a number, return x.__int__(). for floating point 8 numbers, this truncates towards zero. 9 10 if x is not a number or if base is given, then x must be a string, 11 bytes, or bytearray instance representing an integer literal in the 12 given base. the literal can be preceded by '+' or '-' and be surrounded 13 by whitespace. the base defaults to 10. valid bases are 0 and 2-36. 14 base 0 means to interpret the base from the string as an integer literal. 15 >>> int('0b100', base=0) 16 4 17 """ 18 def bit_length(self): # real signature unknown; restored from __doc__ 19 """ 20 number of bits necessary to represent self in binary. 21 22 >>> bin(37) 23 '0b100101' 24 >>> (37).bit_length() 25 6 26 """ 27 pass 28 29 def conjugate(self, *args, **kwargs): # real signature unknown 30 """ returns self, the complex conjugate of any int. """ 31 pass 32 33 @classmethod # known case 34 def from_bytes(cls, *args, **kwargs): # real signature unknown 35 """ 36 return the integer represented by the given array of bytes. 37 38 bytes 39 holds the array of bytes to convert. the argument must either 40 support the buffer protocol or be an iterable object producing bytes. 41 bytes and bytearray are examples of built-in objects that support the 42 buffer protocol. 43 byteorder 44 the byte order used to represent the integer. if byteorder is 'big', 45 the most significant byte is at the beginning of the byte array. if 46 byteorder is 'little', the most significant byte is at the end of the 47 byte array. to request the native byte order of the host system, use 48 `sys.byteorder' as the byte order value. 49 signed 50 indicates whether two's complement is used to represent the integer. 51 """ 52 pass 53 54 def to_bytes(self, *args, **kwargs): # real signature unknown 55 """ 56 return an array of bytes representing an integer. 57 58 length 59 length of bytes object to use. an overflowerror is raised if the 60 integer is not representable with the given number of bytes. 61 byteorder 62 the byte order used to represent the integer. if byteorder is 'big', 63 the most significant byte is at the beginning of the byte array. if 64 byteorder is 'little', the most significant byte is at the end of the 65 byte array. to request the native byte order of the host system, use 66 `sys.byteorder' as the byte order value. 67 signed 68 determines whether two's complement is used to represent the integer. 69 if signed is false and a negative integer is given, an overflowerror 70 is raised. 71 """ 72 pass 73 74 def __abs__(self, *args, **kwargs): # real signature unknown 75 """ abs(self) """ 76 pass 77 78 def __add__(self, *args, **kwargs): # real signature unknown 79 """ return self+value. """ 80 pass 81 82 def __and__(self, *args, **kwargs): # real signature unknown 83 """ return self&value. """ 84 pass 85 86 def __bool__(self, *args, **kwargs): # real signature unknown 87 """ self != 0 """ 88 pass 89 90 def __ceil__(self, *args, **kwargs): # real signature unknown 91 """ ceiling of an integral returns itself. """ 92 pass 93 94 def __divmod__(self, *args, **kwargs): # real signature unknown 95 """ return divmod(self, value). """ 96 pass 97 98 def __eq__(self, *args, **kwargs): # real signature unknown 99 """ return self==value. """ 100 pass 101 102 def __float__(self, *args, **kwargs): # real signature unknown 103 """ float(self) """ 104 pass 105 106 def __floordiv__(self, *args, **kwargs): # real signature unknown 107 """ return self//value. """ 108 pass 109 110 def __floor__(self, *args, **kwargs): # real signature unknown 111 """ flooring an integral returns itself. """ 112 pass 113 114 def __format__(self, *args, **kwargs): # real signature unknown 115 pass 116 117 def __getattribute__(self, *args, **kwargs): # real signature unknown 118 """ return getattr(self, name). """ 119 pass 120 121 def __getnewargs__(self, *args, **kwargs): # real signature unknown 122 pass 123 124 def __ge__(self, *args, **kwargs): # real signature unknown 125 """ return self>=value. """ 126 pass 127 128 def __gt__(self, *args, **kwargs): # real signature unknown 129 """ return self>value. """ 130 pass 131 132 def __hash__(self, *args, **kwargs): # real signature unknown 133 """ return hash(self). """ 134 pass 135 136 def __index__(self, *args, **kwargs): # real signature unknown 137 """ return self converted to an integer, if self is suitable for use as an index into a list. """ 138 pass 139 140 def __init__(self, x, base=10): # known special case of int.__init__ 141 """ 142 int([x]) -> integer 143 int(x, base=10) -> integer 144 145 convert a number or string to an integer, or return 0 if no arguments 146 are given. if x is a number, return x.__int__(). for floating point 147 numbers, this truncates towards zero. 148 149 if x is not a number or if base is given, then x must be a string, 150 bytes, or bytearray instance representing an integer literal in the 151 given base. the literal can be preceded by '+' or '-' and be surrounded 152 by whitespace. the base defaults to 10. valid bases are 0 and 2-36. 153 base 0 means to interpret the base from the string as an integer literal. 154 >>> int('0b100', base=0) 155 4 156 # (copied from class doc) 157 """ 158 pass 159 160 def __int__(self, *args, **kwargs): # real signature unknown 161 """ int(self) """ 162 pass 163 164 def __invert__(self, *args, **kwargs): # real signature unknown 165 """ ~self """ 166 pass 167 168 def __le__(self, *args, **kwargs): # real signature unknown 169 """ return self<=value. """ 170 pass 171 172 def __lshift__(self, *args, **kwargs): # real signature unknown 173 """ return self<<value. """ 174 pass 175 176 def __lt__(self, *args, **kwargs): # real signature unknown 177 """ return self<value. """ 178 pass 179 180 def __mod__(self, *args, **kwargs): # real signature unknown 181 """ return self%value. """ 182 pass 183 184 def __mul__(self, *args, **kwargs): # real signature unknown 185 """ return self*value. """ 186 pass 187 188 def __neg__(self, *args, **kwargs): # real signature unknown 189 """ -self """ 190 pass 191 192 @staticmethod # known case of __new__ 193 def __new__(*args, **kwargs): # real signature unknown 194 """ create and return a new object. see help(type) for accurate signature. """ 195 pass 196 197 def __ne__(self, *args, **kwargs): # real signature unknown 198 """ return self!=value. """ 199 pass 200 201 def __or__(self, *args, **kwargs): # real signature unknown 202 """ return self|value. """ 203 pass 204 205 def __pos__(self, *args, **kwargs): # real signature unknown 206 """ +self """ 207 pass 208 209 def __pow__(self, *args, **kwargs): # real signature unknown 210 """ return pow(self, value, mod). """ 211 pass 212 213 def __radd__(self, *args, **kwargs): # real signature unknown 214 """ return value+self. """ 215 pass 216 217 def __rand__(self, *args, **kwargs): # real signature unknown 218 """ return value&self. """ 219 pass 220 221 def __rdivmod__(self, *args, **kwargs): # real signature unknown 222 """ return divmod(value, self). """ 223 pass 224 225 def __repr__(self, *args, **kwargs): # real signature unknown 226 """ return repr(self). """ 227 pass 228 229 def __rfloordiv__(self, *args, **kwargs): # real signature unknown 230 """ return value//self. """ 231 pass 232 233 def __rlshift__(self, *args, **kwargs): # real signature unknown 234 """ return value<<self. """ 235 pass 236 237 def __rmod__(self, *args, **kwargs): # real signature unknown 238 """ return value%self. """ 239 pass 240 241 def __rmul__(self, *args, **kwargs): # real signature unknown 242 """ return value*self. """ 243 pass 244 245 def __ror__(self, *args, **kwargs): # real signature unknown 246 """ return value|self. """ 247 pass 248 249 def __round__(self, *args, **kwargs): # real signature unknown 250 """ 251 rounding an integral returns itself. 252 rounding with an ndigits argument also returns an integer. 253 """ 254 pass 255 256 def __rpow__(self, *args, **kwargs): # real signature unknown 257 """ return pow(value, self, mod). """ 258 pass 259 260 def __rrshift__(self, *args, **kwargs): # real signature unknown 261 """ return value>>self. """ 262 pass 263 264 def __rshift__(self, *args, **kwargs): # real signature unknown 265 """ return self>>value. """ 266 pass 267 268 def __rsub__(self, *args, **kwargs): # real signature unknown 269 """ return value-self. """ 270 pass 271 272 def __rtruediv__(self, *args, **kwargs): # real signature unknown 273 """ return value/self. """ 274 pass 275 276 def __rxor__(self, *args, **kwargs): # real signature unknown 277 """ return value^self. """ 278 pass 279 280 def __sizeof__(self, *args, **kwargs): # real signature unknown 281 """ returns size in memory, in bytes. """ 282 pass 283 284 def __str__(self, *args, **kwargs): # real signature unknown 285 """ return str(self). """ 286 pass 287 288 def __sub__(self, *args, **kwargs): # real signature unknown 289 """ return self-value. """ 290 pass 291 292 def __truediv__(self, *args, **kwargs): # real signature unknown 293 """ return self/value. """ 294 pass 295 296 def __trunc__(self, *args, **kwargs): # real signature unknown 297 """ truncating an integral returns itself. """ 298 pass 299 300 def __xor__(self, *args, **kwargs): # real signature unknown 301 """ return self^value. """ 302 pass 303 304 denominator = property(lambda self: object(), lambda self, v: none, lambda self: none) # default 305 """the denominator of a rational number in lowest terms""" 306 307 imag = property(lambda self: object(), lambda self, v: none, lambda self: none) # default 308 """the imaginary part of a complex number""" 309 310 numerator = property(lambda self: object(), lambda self, v: none, lambda self: none) # default 311 """the numerator of a rational number in lowest terms""" 312 313 real = property(lambda self: object(), lambda self, v: none, lambda self: none) # default 314 """the real part of a complex number"""
上一篇: 有些人是这样搞笑的.
下一篇: js Set对象