1.3 python数据类型之int类

Posted rodger

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了1.3 python数据类型之int类相关的知识,希望对你有一定的参考价值。

类名:int

  1     def bit_length(self):  # real signature unknown; restored from __doc__
  2         """ 返回用二进制表示该数字需要的最少位数 """
  3         """
  4         int.bit_length() -> int
  5 
  6         Number of bits necessary to represent self in binary.
  7         >>> bin(37)
  8         ‘0b100101‘
  9         >>> (37).bit_length()
 10         6
 11         """
 12         return 0
 13 
 14     def conjugate(self, *args, **kwargs):  # real signature unknown
 15         """ 返回该数字的共轭复数 """
 16         """ Returns self, the complex conjugate of any int. """
 17         pass
 18 
 19     @classmethod  # known case
 20     def from_bytes(cls, bytes, byteorder, *args,**kwargs):  # real signature unknown; NOTE: unreliably restored from __doc__
 21         """ 将字节转换成相应的数字,其中byte是字节;byteorder是字节顺序,big是高字节在后低字节在前
 22             little是低字节在后,高字节在前;signed表示的是有符号和无符号
 23         """
 24         """
 25         int.from_bytes(bytes, byteorder, *, signed=False) -> int
 26 
 27         Return the integer represented by the given array of bytes.
 28 
 29         The bytes argument must be a bytes-like object (e.g. bytes or bytearray).
 30 
 31         The byteorder argument determines the byte order used to represent the
 32         integer.  If byteorder is ‘big‘, the most significant byte is at the
 33         beginning of the byte array.  If byteorder is ‘little‘, the most
 34         significant byte is at the end of the byte array.  To request the native
 35         byte order of the host system, use `sys.byteorder‘ as the byte order value.
 36 
 37         The signed keyword-only argument indicates whether two‘s complement is
 38         used to represent the integer.
 39         """
 40         pass
 41 
 42     def to_bytes(self, length, byteorder, *args,**kwargs):  # real signature unknown; NOTE: unreliably restored from __doc__
 43         """ 把数字转换成字节类型的格式,from_bytes的过程 """
 44         """
 45         int.to_bytes(length, byteorder, *, signed=False) -> bytes
 46 
 47         Return an array of bytes representing an integer.
 48 
 49         The integer is represented using length bytes.  An OverflowError is
 50         raised if the integer is not representable with the given number of
 51         bytes.
 52 
 53         The byteorder argument determines the byte order used to represent the
 54         integer.  If byteorder is ‘big‘, the most significant byte is at the
 55         beginning of the byte array.  If byteorder is ‘little‘, the most
 56         significant byte is at the end of the byte array.  To request the native
 57         byte order of the host system, use `sys.byteorder‘ as the byte order value.
 58 
 59         The signed keyword-only argument determines whether two‘s complement is
 60         used to represent the integer.  If signed is False and a negative integer
 61         is given, an OverflowError is raised.
 62         """
 63         pass
 64 
 65     def __abs__(self, *args, **kwargs):  # real signature unknown
 66         """ 取绝对值 """
 67         """ abs(self) """
 68         pass
 69 
 70     def __add__(self, *args, **kwargs):  # real signature unknown
 71         """ 求和运算 """
 72         """ Return self+value. """
 73         pass
 74 
 75     def __and__(self, *args, **kwargs):  # real signature unknown
 76         """ 按位与运算 """
 77         """ Return self&value. """
 78         pass
 79 
 80     def __bool__(self, *args, **kwargs):  # real signature unknown
 81         """ 返回布尔值,非0数的布尔值是True,0的布尔值是False """
 82         """  """
 83         """ self != 0 """
 84         pass
 85 
 86     def __ceil__(self, *args, **kwargs):  # real signature unknown
 87         """ 返回这个整数本身 """
 88         """ Ceiling of an Integral returns itself. """
 89         pass
 90 
 91     def __divmod__(self, *args, **kwargs):  # real signature unknown
 92         """ (num1).__divmod__(num2) 将num1除以num2,返回的是一个格式为(商,余数)的元组 """
 93         """ Return divmod(self, value). """
 94         pass
 95 
 96     def __eq__(self, *args, **kwargs):  # real signature unknown
 97         """ (num1).__eq__(num2)  比较num1和num2的值,相等返回True,不等返回False """
 98         """ Return self==value. """
 99         pass
100 
101     def __float__(self, *args, **kwargs):  # real signature unknown
102         """ 将数字从整数类型转换成浮点类型 """
103         """ float(self) """
104         pass
105 
106     def __floordiv__(self, *args, **kwargs):  # real signature unknown
107         """ 地板除,相当于 // 运算 """
108         """ Return self//value. """
109         pass
110 
111     def __floor__(self, *args, **kwargs):  # real signature unknown
112         """ 返回这个数本身 """
113         """ Flooring an Integral returns itself. """
114         pass
115 
116     def __format__(self, *args, **kwargs):  # real signature unknown
117         pass
118 
119     def __getattribute__(self, *args, **kwargs):  # real signature unknown
120         """ x.__getattribute__(‘name‘) == x.name """
121         """ Return getattr(self, name). """
122         pass
123 
124     def __getnewargs__(self, *args, **kwargs):  # real signature unknown
125         """ 内部调用 __new__方法或创建对象时传入参数使用 """
126         pass
127 
128     def __ge__(self, *args, **kwargs):  # real signature unknown
129         """ (num1).__ge__(num2) 如果num1大于或等于num2,则返回True,否则返回False """
130         """ Return self>=value. """
131         pass
132 
133     def __gt__(self, *args, **kwargs):  # real signature unknown
134         """ (num1).__ge__(num2) 如果num1大于num2,则返回True,否则返回False """
135         """ Return self>value. """
136         pass
137 
138     def __hash__(self, *args, **kwargs):  # real signature unknown
139         """ 如果对象object为哈希表类型,返回对象object的哈希值。哈希值为整数。
140         在字典查找中,哈希值用于快速比较字典的键。两个数值如果相等,则哈希值也相等 """
141         """ Return hash(self). """
142         pass
143 
144     def __index__(self, *args, **kwargs):  # real signature unknown
145         """ 用于切片,数字无意义
146             x[y:z] <==> x[y.__index__():z.__index__()]
147         """
148         """ Return self converted to an integer, if self is suitable for use as an index into a list. """
149         pass
150 
151     def __init__(self, x, base=10):  # known special case of int.__init__
152         """ 构造方法,创建int对象时自动调用 """
153         """
154         int(x=0) -> integer
155         int(x, base=10) -> integer
156 
157         Convert a number or string to an integer, or return 0 if no arguments
158         are given.  If x is a number, return x.__int__().  For floating point
159         numbers, this truncates towards zero.
160 
161         If x is not a number or if base is given, then x must be a string,
162         bytes, or bytearray instance representing an integer literal in the
163         given base.  The literal can be preceded by ‘+‘ or ‘-‘ and be surrounded
164         by whitespace.  The base defaults to 10.  Valid bases are 0 and 2-36.
165         Base 0 means to interpret the base from the string as an integer literal.
166         >>> int(‘0b100‘, base=0)
167         4
168         # (copied from class doc)
169         """
170         pass
171 
172     def __int__(self, *args, **kwargs):  # real signature unknown
173         """ 转换成整数类型 """
174         """ int(self) """
175         pass
176 
177     def __invert__(self, *args, **kwargs):  # real signature unknown
178         """ 按位取反, (x).__invert__()类似于-x-1  """
179         """ ~self """
180         pass
181 
182     def __le__(self, *args, **kwargs):  # real signature unknown
183         """ (num1).__ge__(num2) 如果num1小于或等于num2,则返回True,否则返回False """
184         """ Return self<=value. """
185         pass
186 
187     def __lshift__(self, *args, **kwargs):  # real signature unknown
188         """ """
189         """ Return self<<value. """
190         pass
191 
192     def __lt__(self, *args, **kwargs):  # real signature unknown
193         """ (num1).__ge__(num2) 如果num1小于num2,则返回True,否则返回False """
194         """ Return self<value. """
195         pass
196 
197     def __mod__(self, *args, **kwargs):  # real signature unknown
198         """ 取模运算 """
199         """ Return self%value. """
200         pass
201 
202     def __mul__(self, *args, **kwargs):  # real signature unknown
203         """ 乘法运算 """
204         """ Return self*value. """
205         pass
206 
207     def __neg__(self, *args, **kwargs):  # real signature unknown
208         """ (x).__neg() <==> -(x) """
209         """ -self """
210         pass
211 
212     @staticmethod  # known case of __new__
213     def __new__(*args, **kwargs):  # real signature unknown
214         """ Create and return a new object.  See help(type) for accurate signature. """
215         pass
216 
217     def __ne__(self, *args, **kwargs):  # real signature unknown
218         """ x.__ne__(y) 如果x与y的值不相等,返回True,相等则返回False """
219         """ Return self!=value. """
220         """  """
221         pass
222 
223     def __or__(self, *args, **kwargs):  # real signature unknown
224         """ 按位或运算 """
225         """ Return self|value. """
226         pass
227 
228     def __pos__(self, *args, **kwargs):  # real signature unknown
229         """ (x).__pos__()  <==> +(x) """
230         """ +self """
231         pass
232 
233     def __pow__(self, *args, **kwargs):  # real signature unknown
234         """ (x).__pow__(y)  <==> x**y """
235         """ Return pow(self, value, mod). """
236         pass
237 
238     def __radd__(self, *args, **kwargs):  # real signature unknown
239         """ 后面的数加上前面的数 """
240         """ Return value+self. """
241         pass
242 
243     def __rand__(self, *args, **kwargs):  # real signature unknown
244         """ 后面的数对前面的数进行按位与运算 """
245         """ Return value&self. """
246         pass
247 
248     def __rdivmod__(self, *args, **kwargs):  # real signature unknown
249         """ (num1).__divmod__(num2) 将num2除以num1,返回的是一个格式为(商,余数)的元组 """
250         """ Return divmod(value, self). """
251         pass
252 
253     def __repr__(self, *args, **kwargs):  # real signature unknown
254         """ 转化为解释器可读取的形式 """
255         """ Return repr(self). """
256         pass
257 
258     def __rfloordiv__(self, *args, **kwargs):  # real signature unknown
259         """ 后面的数对前面的数进行取整除运算 """
260         """ Return value//self. """
261         pass
262 
263     def __rlshift__(self, *args, **kwargs):  # real signature unknown
264         """ 左移 (x).__lshift__(y) 相当与y*2^x """
265         """ Return value<<self. """
266         pass
267 
268     def __rmod__(self, *args, **kwargs):  # real signature unknown
269         """ 后面的数与前面的数进行取模运算 """
270         """ Return value%self. """
271         pass
272 
273     def __rmul__(self, *args, **kwargs):  # real signature unknown
274         """ 后面的数乘以前面的数 """
275         """ Return value*self. """
276         pass
277 
278     def __ror__(self, *args, **kwargs):  # real signature unknown
279         """ 后面的数和前面的数进行按位或运算 """
280         """ Return value|self. """
281         pass
282 
283     def __round__(self, *args, **kwargs):  # real signature unknown
284         """ 返回小数点四舍五入到N个数字,整型无意义 """
285         """
286         Rounding an Integral returns itself.
287         Rounding with an ndigits argument also returns an integer.
288         """
289         pass
290 
291     def __rpow__(self, *args, **kwargs):  # real signature unknown
292         """ (x).__rpow__(y) <==> y**x """
293         """ Return pow(value, self, mod). """
294         pass
295 
296     def __rrshift__(self, *args, **kwargs):  # real signature unknown
297         """ 右移 (x).__rrshift__(y) 相当于y//(2^x) """
298         """ Return value>>self. """
299         pass
300 
301     def __rshift__(self, *args, **kwargs):  # real signature unknown
302         """ 右移 (x).__rshift__(y) 相当于x//(2^y) """
303         """ Return self>>value. """
304         pass
305 
306     def __rsub__(self, *args, **kwargs):  # real signature unknown
307         """ 后面的数减去前面的数 """
308         """ Return value-self. """
309         pass
310 
311     def __rtruediv__(self, *args, **kwargs):  # real signature unknown
312         """ 将后面的数除以前面的数 """
313         """ Return value/self. """
314         pass
315 
316     def __rxor__(self, *args, **kwargs):  # real signature unknown
317         """ 将后面的数与前面的数按位异或 """
318         """ Return value^self. """
319         pass
320 
321     def __sizeof__(self, *args, **kwargs):  # real signature unknown
322         """ 返回占用的字节数 """
323         """ Returns size in memory, in bytes """
324         pass
325 
326     def __str__(self, *args, **kwargs):  # real signature unknown
327         """ 转换成可读取的形式 """
328         """ Return str(self). """
329         pass
330 
331     def __sub__(self, *args, **kwargs):  # real signature unknown
332         """ 将前面的数减去后面的数 """
333         """ Return self-value. """
334         pass
335 
336     def __truediv__(self, *args, **kwargs):  # real signature unknown
337         """ 将前面的数除以后面的数 """
338         """ Return self/value. """
339         pass
340 
341     def __trunc__(self, *args, **kwargs):  # real signature unknown
342         """ 返回数值被截取为整型的值,在整型中无意义 """
343         """ Truncating an Integral returns itself. """
344         pass
345 
346     def __xor__(self, *args, **kwargs):  # real signature unknown
347         """ 将前面的数与后面的数按位异或 """
348         """ Return self^value. """
349         pass

 

以上是关于1.3 python数据类型之int类的主要内容,如果未能解决你的问题,请参考以下文章

python3.6数据类型之int类型

python基本数据类型都有哪些

Python 数据类型之int

JAVA 1.3 (原生数据类型 Primitive Data Type)续

Python基本数据类型之数字int

数据类型之整型(int)