class int(object)

| int(x=0) -> integer
| int(x, base=10) -> integer
|

| Convert a number or string to an integer, or return 0 if no arguments
| are given. If x is a number, return x.__int__(). For floating point
| numbers, this truncates towards zero.

| If x is not a number or if base is given, then x must be a string,
| bytes, or bytearray instance representing an integer literal in the
| given base. The literal can be preceded by '+' or '-' and be surrounded
| by whitespace. The base defaults to 10. Valid bases are 0 and 2-36.
| Base 0 means to interpret the base from the string as an integer literal.

| 将一个数字或字符串转换成整数,没有参数的时候为默认值0。如果参数时数字,调用__init__(),参数为浮点数,会发生截取。

|当x参数时不是数字时,或者有参数base,那么x参数一定是字面值是整数的字符串,字节流,或者是字节数组。这个字面值可以有正负号,前后可以有空格。

|base参数默认是10,base允许是0,2到36。如果base是0的时候,会根据字符串的字面值判断base的值。

 a = int('', )
print(a)
a = int('0b100', )
print(a)
 

| >>> int('0b100', base=0)
| 4
|
| Methods defined here:
|
| __abs__(self, /)
| abs(self)

 print(abs(-))
print(abs())
 

|
| __add__(self, value, /)
| Return self+value.

 print( +  + )
 

|
| __and__(self, value, /)
| Return self&value.

 print( & )
 

|
| __bool__(self, /)
| self != 0

 if :
print("True")
if :
pass
else:
print("False")
 True
False

|
| __ceil__(...)
| Ceiling of an Integral returns itself.

返回一个大于或者等于x的最小整数。

 import math
print(math.ceil())
print(math.ceil(9.2))
print(math.ceil(-8.2))

 -

|
| __divmod__(self, value, /)
| Return divmod(self, value).

返回一个元组,一个值是x//y,第二个值是x%y。

 print(divmod(, ))
 (, )

|
| __eq__(self, value, /)
| Return self==value.

 print( == )
 True

|
| __float__(self, /)
| float(self)

 print(float())
 5.0

|
| __floor__(...)
| Flooring an Integral returns itself.

返回数字的下舍整数。

 >>> import math
>>> math.floor(5)
5
>>> math.floor(5.1)
5
>>> math.floor(-5.1)
-6

|
| __floordiv__(self, value, /)
| Return self//value.

地板除。

 >>> 5//2
2

|
| __format__(...)
| default object formatter

|
| __ge__(self, value, /)
| Return self>=value.

 >>> 10 >= 5
True

|
| __getattribute__(self, name, /)
| Return getattr(self, name).

|
| __getnewargs__(...)

|
| __gt__(self, value, /)
| Return self>value.

 >>> 10 > 5
True

|
| __hash__(self, /)
| Return hash(self).

获取一个对象(字符串或者数值等)的哈希值。

 >>> hash(15)
15
>>> hash(15.5)
1152921504606846991
>>> hash('wang')
-1275867606344747311

|
| __index__(self, /)
| Return self converted to an integer, if self is suitable for use as an index into a list.

|
| __int__(self, /)
| int(self)

 >>> int(10)
10
>>> int(10.10)
10

|
| __invert__(self, /)
| ~self

 >>> ~0
-1
>>> ~1
-2
>>> ~-1
0
>>> ~-2
1

|
| __le__(self, value, /)
| Return self<=value.

 >>> 10 <= 5
False

|
| __lshift__(self, value, /)
| Return self<<value.

 >>> 1 << 1
2

|
| __lt__(self, value, /)
| Return self<value.

 >>> 1 < 1
False

|
| __mod__(self, value, /)
| Return self%value.

 >>> 5 % 2
1

|
| __mul__(self, value, /)
| Return self*value.

 >>> 5 * 2
10

|
| __ne__(self, value, /)
| Return self!=value.

 >>> 5 != 2
True

|
| __neg__(self, /)
| -self

 >>> -10
-10
>>> --10
10

|
| __new__(*args, **kwargs) from builtins.type
| Create and return a new object. See help(type) for accurate signature.

|
| __or__(self, value, /)
| Return self|value.

 >>> 1 | 0
1

|
| __pos__(self, /)
| +self

 >>> +5
5
>>> +-5
-5

|
| __pow__(self, value, mod=None, /)
| Return pow(self, value, mod).

 >>> pow(2, 2)
4
>>> pow(3, 3)
27

|
| __radd__(self, value, /)
| Return value+self.

|
| __rand__(self, value, /)
| Return value&self.
|
| __rdivmod__(self, value, /)
| Return divmod(value, self).

|
| __repr__(self, /)
| Return repr(self).

 >>> repr(10)
''

|
| __rfloordiv__(self, value, /)
| Return value//self.
|
| __rlshift__(self, value, /)
| Return value<<self.
|
| __rmod__(self, value, /)
| Return value%self.
|
| __rmul__(self, value, /)
| Return value*self.
|
| __ror__(self, value, /)
| Return value|self.
|
| __round__(...)
| Rounding an Integral returns itself.
| Rounding with an ndigits argument also returns an integer.

|
| __rpow__(self, value, mod=None, /)
| Return pow(value, self, mod).
|
| __rrshift__(self, value, /)
| Return value>>self.
|
| __rshift__(self, value, /)
| Return self>>value.
|
| __rsub__(self, value, /)
| Return value-self.
|
| __rtruediv__(self, value, /)
| Return value/self.
|
| __rxor__(self, value, /)
| Return value^self.
|
| __sizeof__(...)
| Returns size in memory, in bytes

|
| __str__(self, /)
| Return str(self).
|
| __sub__(self, value, /)
| Return self-value.
|
| __truediv__(self, value, /)
| Return self/value.
|
| __trunc__(...)
| Truncating an Integral returns itself.
|
| __xor__(self, value, /)
| Return self^value.
|
| bit_length(...)
| int.bit_length() -> int
|
| Number of bits necessary to represent self in binary.
| >>> bin(37)
| '0b100101'
| >>> (37).bit_length()
| 6
|
| conjugate(...)
| Returns self, the complex conjugate of any int.
|
| from_bytes(...) from builtins.type
| int.from_bytes(bytes, byteorder, *, signed=False) -> int
|
| Return the integer represented by the given array of bytes.
|
| The bytes argument must be a bytes-like object (e.g. bytes or bytearray).
|
| The byteorder argument determines the byte order used to represent the
| integer. If byteorder is 'big', the most significant byte is at the
| beginning of the byte array. If byteorder is 'little', the most
| significant byte is at the end of the byte array. To request the native
| byte order of the host system, use `sys.byteorder' as the byte order value.
|
| The signed keyword-only argument indicates whether two's complement is
| used to represent the integer.
|
| to_bytes(...)
| int.to_bytes(length, byteorder, *, signed=False) -> bytes
|
| Return an array of bytes representing an integer.
|
| The integer is represented using length bytes. An OverflowError is
| raised if the integer is not representable with the given number of
| bytes.
|
| The byteorder argument determines the byte order used to represent the
| integer. If byteorder is 'big', the most significant byte is at the
| beginning of the byte array. If byteorder is 'little', the most
| significant byte is at the end of the byte array. To request the native
| byte order of the host system, use `sys.byteorder' as the byte order value.
|
| The signed keyword-only argument determines whether two's complement is
| used to represent the integer. If signed is False and a negative integer
| is given, an OverflowError is raised.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| denominator
| the denominator of a rational number in lowest terms
|
| imag
| the imaginary part of a complex number
|
| numerator
| the numerator of a rational number in lowest terms
|
| real
| the real part of a complex number

最新文章

  1. [LeetCode] Rank Scores 分数排行
  2. 第七篇——Mobile Apps,软件的曙光。
  3. android开发练习:天气应用
  4. SQL Server 2008 R2——VC++ ADO 操作 重复利用_ParameterPtr
  5. 从一个action地址获取信息
  6. 元素过滤器(Element Filters)
  7. log4.net
  8. 安装J2EE的SDK报错:could not find the required version of the Java(TM)2 Runtime Environment in &#39;(null)&#39;的解决办法。
  9. gulp快速入门
  10. 在ASP.NET MVC中使用IIS级别的URL Rewrite
  11. [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property &#39;source&#39; to &#39;org.eclipse.js
  12. 使用mysql5.7新特性(虚拟列)解决使用前通配符性能问题
  13. K:二叉树的非递归遍历
  14. python_改变字符串中文本格式?
  15. ●BZOJ 2154 Crash的数字表格
  16. SDL2源代码分析1:初始化(SDL_Init())
  17. Python3 与 C# 并发编程之~ Net篇
  18. linux虚拟机配置上网(静态IP)和配置tomcat服务环境
  19. Android关于log日志,华为不输出log.v,log.d(zz)
  20. 基于JSP的RSS阅读器的设计与实现

热门文章

  1. 一个简单的QQ隐藏图生成算法 通过jQuery和C#分别实现对.NET Core Web Api的访问以及文件上传
  2. POJ 3414:Pots
  3. (WPF)Storyboard
  4. mac上pydev
  5. Phoenix put the sql back in NoSql
  6. monggodb 复制集 集群 搭建
  7. inheritance super overrides printMethod in Superclass override重写父方法
  8. 数字和为sum的方法数(动态规划)
  9. RabbitMQ使用简述
  10. js判断字符串是否包含某个字符串