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. FastDFS的配置、部署与API使用解读(1)Get Started with FastDFS(转)

    转载请注明来自:诗商·柳惊鸿CSDN博客,原文链接:FastDFS的配置.部署与API使用解读(1)入门使用教程 1.背景 FastDFS是一款开源的.分布式文件系统(Distributed File ...

  2. AliYunDun关闭

    停止阿里云盾AliYunDun服务解决大量写磁盘问题-小内存ECS服务器 阿里云数据库在没备案,涉及大量IO操作时会自动启动阿里云盾这个服务,会导致服务器变得很卡 关闭服务: service aegi ...

  3. spring test---測试SpringMvc初识

    如今越来越多人使用SpringMvc来开发系统,在开发中可定须要对后台url地址请求測试,而且返回预期的结果! Spring提供的測试类MockMvc来进行url地址请求測试,使用方方式: packa ...

  4. 防sql注入 盲注等措施 ESAPI的使用

    SQL注入往往是在程序员编写包含用户输入的动态数据库查询时产生的,但其实防范SQL注入的方法非常简单.程序员只要a)不再写动态查询,或b)防止用户输入包含能够破坏查询逻辑的恶意SQL语句,就能够防范S ...

  5. php网站前台utf-8格式有时会出现莫名其妙的空白行,重新保存下编码格式就可以了

    php网站前台utf-8格式有时会出现莫名其妙的空白行,重新保存下编码格式就可以了.

  6. EasyUI+Python-flask实现CRUD应用

    1.需求分析 需求:应用easyui制作前端表格数据显示,flask制作后端路由 环境搭建略 2.easyui前端实现 2.1 easyui是前端实用的一个框架,这里我们要实现的是easyui的CRU ...

  7. 使用pt-query-digest进行日志分析

    使用pt-query-digest sudo apt install percona-toolkit 也可以到官网 https://www.percona.com/downloads/percona- ...

  8. codeforces 443 B. Kolya and Tandem Repeat 解题报告

    题目链接:http://codeforces.com/contest/443/problem/B 题目意思:给出一个只有小写字母的字符串s(假设长度为len),在其后可以添加 k 个长度的字符,形成一 ...

  9. A+B Problem && OJ推荐【持续更新】

    目录 List 前言 长郡 Position: code 1. 2. 持续更新,么么哒 List 前言 有没有觉得写这篇文章很奇怪,这个还是有原因的.①很多OJ都有着道题,所以发个博客②这可以介绍很多 ...

  10. hdu-5675 ztr loves math(数学)

    题目链接: ztr loves math  Time Limit: 2000/1000 MS (Java/Others)  Memory Limit: 65536/65536 K (Java/Othe ...