python help(int)
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)的更多相关文章
- python 实现int函数
拖了这么久,最终还是战胜了懒惰,打开电脑写了这篇博客,内容也很简单,python实现字符串转整型的int方法 python已经实现了int方法,我们为什么还要再写一遍,直接用不就好了?事实确实如此,但 ...
- Python中int()函数的用法浅析
int()是Python的一个内部函数 Python系统帮助里面是这么说的 >>> help(int) Help on class int in module __builti ...
- 一、python (int & str 的方法)
1.变量:命名与使用 #!/usr/bin/env/ python # -*- coding:utf-8 -*- name = 'liQM' 只能包含字母.数字或下划线: 第一个字符不能是数字: 简短 ...
- Python中int,bool,str,格式化,少量is,已经for循环练习
1.整数 十进制转化为二进制 xxx.bit_length(). #求十进制数转化成二进制时所占用的位数 2.布尔值 bool # 布尔值 - - 用于条件使用 True 真 Fa ...
- 零基础如何学好Python 之int 数字整型类型 定义int()范围大小转换
本文主题是讲python数字类型python int整型使用方法及技巧.它是不可变数据类型中的一种,它的一些性质和字符串是一样的,注意是整型不是整形哦. Python int有多种数字类型:整型int ...
- python day3 int,str,list类型补充
目录 python day 3 1. int类小知识点 2. str类小知识点 3. list类小知识点 python day 3 (学习资料来自老男孩教育) 2019/10/06 1. int类小知 ...
- python中int是什么类型
python中的基本数据类型 1:虽然python中的变量不需要声明,但使用时必须赋值整形变量浮点型变量字符型2:可以一个给多个变量赋值,也可以多个给多个变量赋值3:python3中有6个标准数据类型 ...
- Python学习笔记之基础篇(三)python 数据类型 int str bool 详谈
python 的数据类型: 1.int:存放 1,2,3 等数据 ,用于数字的运算 2.bool :True, False 用于判断 3.str:字符串,用来存储少量的数据 4.list : 数组的 ...
- python str + int
TypeError: cannot concatenate 'str' and 'int' objects 1. print 'Is your secret number " + str(p ...
- Python之int内部功能介绍
int内部功能的介绍 type(): 1.基本数据类型使用type()函数时,得到相应的数据类型a = 12b = 12.01c = "123"print(type(a)) > ...
随机推荐
- 关于 redux-saga 中 take 使用方法详解
本文介绍了关于redux-saga中take使用方法详解,分享给大家,具体如下: 带来一个自己研究好久的API使用方法. redux-saga中effect中take这个API使用方式,用的多的是ca ...
- Ubuntu 14.04安装搜狗拼音linux版应该注意的问题
Ubuntu 14.04最终在万千期盼中来了,我也像其他的linux爱好者一样,删除了旧的12.04.開始体验下一个到来的LTS版本号. 我不想安装Ubuntu 麒麟版,我仅仅想原汁原味的Ubuntu ...
- 全文索引--自己定义chinese_lexer词典
本文来具体解释一下怎样自己定义chinese_lexer此法分析器的词典 初始化数据 create table test2 (str1 varchar2(2000),str2varchar2(2000 ...
- HDU 5327 Olympiad (多校)
Olympiad Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Su ...
- Linux安装程序Anaconda分析(续)
本来想写篇关于Anaconda的文章,但看到这里写的这么详细,转,原文在这里:Linux安装程序Anaconda分析(续) (1) disptach.py: 下面我们看一下Dispatcher类的主要 ...
- (转载)解决MySql 数据库 提示:1045 access denied for user 'root'@'localhost' using password yes
今天想用用MySQL 数据库 谁知道老提示 1045 access denied for user 'root'@'localhost' using password yes 最后在csdn 上找到 ...
- C语言socket send()数据缓存问题
send()函数默认情况下会使用Nagle算法.Nagle算法通过将未确认的数据存入缓冲区直到积攒到一定数量一起发送的方法.来降低主机发送零碎小数据包的数目.所以假设send()函数发送数据过快的话, ...
- grunt简单教程
Grunt简单教程 1.grunt简单介绍 Grunt是一个基于任务的命令行工具.依赖于node.js环境. 它能帮你合并js文件,压缩js文件,验证js.编译less,合并css.还能够配置自己主动 ...
- mysql读写分离(主从复制)实现
mysql主从复制 怎么安装mysql数据库,这里不说了,仅仅说它的主从复制.过程例如以下: 主从最好都是同一种系统比方都是linux,或者都是windows,当然混合着也是能够成功,不解释了 1.主 ...
- Drupal 7模板(主题钩子)的建议
这一块的内容很多其它的讲的是样例.所以这里请直接稳步官方站点查看吧.链接 https://drupal.org/node/1089656