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

python help(int)的更多相关文章

  1. python 实现int函数

    拖了这么久,最终还是战胜了懒惰,打开电脑写了这篇博客,内容也很简单,python实现字符串转整型的int方法 python已经实现了int方法,我们为什么还要再写一遍,直接用不就好了?事实确实如此,但 ...

  2. Python中int()函数的用法浅析

      int()是Python的一个内部函数 Python系统帮助里面是这么说的 >>> help(int)  Help on class int in module __builti ...

  3. 一、python (int & str 的方法)

    1.变量:命名与使用 #!/usr/bin/env/ python # -*- coding:utf-8 -*- name = 'liQM' 只能包含字母.数字或下划线: 第一个字符不能是数字: 简短 ...

  4. Python中int,bool,str,格式化,少量is,已经for循环练习

    1.整数 ​ 十进制转化为二进制 ​ xxx.bit_length(). #求十进制数转化成二进制时所占用的位数 2.布尔值 ​ bool # 布尔值 - - 用于条件使用 ​ True 真 ​ Fa ...

  5. 零基础如何学好Python 之int 数字整型类型 定义int()范围大小转换

    本文主题是讲python数字类型python int整型使用方法及技巧.它是不可变数据类型中的一种,它的一些性质和字符串是一样的,注意是整型不是整形哦. Python int有多种数字类型:整型int ...

  6. python day3 int,str,list类型补充

    目录 python day 3 1. int类小知识点 2. str类小知识点 3. list类小知识点 python day 3 (学习资料来自老男孩教育) 2019/10/06 1. int类小知 ...

  7. python中int是什么类型

    python中的基本数据类型 1:虽然python中的变量不需要声明,但使用时必须赋值整形变量浮点型变量字符型2:可以一个给多个变量赋值,也可以多个给多个变量赋值3:python3中有6个标准数据类型 ...

  8. Python学习笔记之基础篇(三)python 数据类型 int str bool 详谈

     python 的数据类型: 1.int:存放 1,2,3 等数据 ,用于数字的运算 2.bool :True, False 用于判断 3.str:字符串,用来存储少量的数据 4.list : 数组的 ...

  9. python str + int

    TypeError: cannot concatenate 'str' and 'int' objects 1. print 'Is your secret number " + str(p ...

  10. Python之int内部功能介绍

    int内部功能的介绍 type(): 1.基本数据类型使用type()函数时,得到相应的数据类型a = 12b = 12.01c = "123"print(type(a)) > ...

随机推荐

  1. 【Objective-C】09-空指针和野指针

    一.什么是空指针和野指针 1.空指针 1> 没有存储不论什么内存地址的指针就称为空指针(NULL指针) 2> 空指针就是被赋值为0的指针.在没有被详细初始化之前.其值为0. 以下两个都是空 ...

  2. Go fsm

    package fsm import ( "log" ) type EvtIf interface { GetEvtType() string } type Action inte ...

  3. Hadoop+HBase+ZooKeeper分布式集群环境搭建

    一.环境说明 集群环境至少需要3个节点(也就是3台服务器设备):1个Master,2个Slave,节点之间局域网连接,可以相互ping通,下面举例说明,配置节点IP分配如下: Hostname IP ...

  4. C++ primer 模板与泛型编程

    继续浏览c++ primer 看到模板与泛型编程这章.就顺便把这几节的代码综合了下,对一个Queue队列模板的实现 贴一下代码(看完书.自己敲,忘记了哪再看下书) #include <ostre ...

  5. LeetCode_3Sum

    一.题目 3Sum Total Accepted: 45112 Total Submissions: 267165My Submissions Given an array S of n intege ...

  6. google protocol buffer的原理和使用(一)

    一.简单的介绍      Protocol buffers是一个用来序列化结构化数据的技术,支持多种语言诸如C++.Java以及Python语言.能够使用该技术来持久化数据或者序列化成网络传输的数据. ...

  7. 使用Swift作为Glance后端存储

    原文链接 http://thornelabs.net/2014/08/03/use-openstack-swift-as-a-backend-store-for-glance.html By defa ...

  8. Linux下VLAN功能的实现 (转)

    1.Linux网络栈下两层实现 1.1简介     VLAN是网络栈的一个附加功能,且位于下两层.首先来学习Linux中网络栈下两层的实现,再去看如何把VLAN这个功能附加上去.下两层涉及到具体的硬件 ...

  9. Arcgis Engine(ae)接口详解(7):地图(map)操作

    IMap map = null; //跟map同一层次的activeView对象,他们都是“地图”的对象,map管理地图内容,activeView管理显示内容 IActiveView activeVi ...

  10. Hadoop每日一讨论整理版

    这是我在几个QQ群发起的Hadoop每日一讨论小活动,每天中午2点左右发出一个关于Hadoop的知识片段,在此做一个整理. [每日一讨论]之计算框架(2013-5-21) 就计算框架而言,Hadoop ...