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)) > ...
随机推荐
- css设置背景图片自适应
CreateTime--2017年12月25日16:36:07 Author:Marydon 控制背景图片100%自适应填充布局 /* 控制背景图片100%自适应填充布局 */ body{ bac ...
- opencv2反投影直方图以检測特定的图像内容
#ifndef HISTOGRAM_H_ #define HISTOGRAM_H_ #include<opencv2/core/core.hpp> #include<opencv2/ ...
- C++结构体中使用函数与类中使用函数小结
#include <iostream>#include <string.h>using namespace std;struct stud//学生信息结构体{ char ...
- Java核心技术之基本数据类型
这篇文章.我们讨论一些java的最主要的东西.这些东西我们一般刚刚学java的时候就学过,可是不一定真正明确. 正好,我在做一个读取内存的值,涉及到bit位的值的读取和写.那就能够讨论一个java的基 ...
- 正则_action
http://wiki.ubuntu.org.cn/index.php?title=Python%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E6%93% ...
- C++设计模式之State模式
这里有两个例子: 1.https://www.cnblogs.com/wanggary/archive/2011/04/21/2024117.html 2.https://www.cnblogs.co ...
- 汉字与区位码互转(天天使用Delphi的String存储的是内码,Windows记事本存储的文件也是内码),几个常见汉字的各种编码,utf8与unicode的编码在线查询,附有读书笔记 good
汉=BABA(内码)=-A0A0=2626(区位码)字=D7D6(内码)=-A0A0=5554(区位码) 各种编码查询表:http://bm.kdd.cc/ 汉(记住它,以后碰到内存里的数值,就会有敏 ...
- ad广告下拉收起代码
1. [代码][JavaScript]代码<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" &qu ...
- 【转载】Android Studio简单设置
界面设置 默认的 Android Studio 为灰色界面,可以选择使用炫酷的黑色界面.Settings --> Appearance --> Theme ,选择 Darcula 主题即可 ...
- hdu 4022 Bombing(map,multiset)
题意:n个基地放在2维平面,然后m个炸弹人,每个炸弹人可以炸一行或者一列,输出每个炸弹人炸掉的基地个数. 思路:用map<int,multiset<int> >对应起来一行或者 ...