文档章节

整型int和长整型long

o
 osc_1ee7cxmx
发布于 2018/08/06 21:17
字数 1312
阅读 0
收藏 0
def
python 一切事物都是对象,对象基于类创建
类:(列表)功能集合
查看对象相关成员:var,type,dir
一、 整数 int
int(x=0) -> int or long int(x, base=10) -> int or long
def bit_length(self): 返回表示该数字的时候占用的最少位数
int.bit_length(*)
eg:int.bit_length(27) ---> 5
说明:27用二进制表示:bin(27) --->'0b11011' (其中ob表示二进制,11011表示27)
def conjugate(self, *args, **kwargs): 返回该复数的共轭复数
def __abs__(self):返回绝对值
x.__abs__() <==> abs(x) def __add__(self, y): 加法
x.__add__(y) <==> x+y def __and__(self, y):
x.__and__(y) <==> x&y def __cmp__(self, y): 比较两个数大小
x.__cmp__(y) <==> cmp(x,y)
def __coerce__(self, y): 强制生成一个元组 x.__coerce__(y) <==> coerce(x, y) def __divmod__(self, y): 相除,得到商和余数组成的元组 x.__divmod__(y) <==> divmod(x, y) def __div__(self, y): x.__div__(y) <==> x/y """ pass def __float__(self): 转换为浮点类型 x.__float__() <==> float(x) def __floordiv__(self, y): x.__floordiv__(y) <==> x//y def __format__(self, *args, **kwargs): # real signature unknown def __getattribute__(self, name): x.__getattribute__('name') <==> x.name
def __getnewargs__(self, *args, **kwargs): 内部调用 __new__方法或创建对象时传入参数使用 def __hash__(self): 如果对象object为哈希表类型,返回对象object的哈希值。哈希值为整数。在字典查找中,哈希值用于快速比较字典的键。两个数值如果相等,则哈希值也相等。 x.__hash__() <==> hash(x) def __hex__(self): 返回当前数的十六进制表示 x.__hex__() <==> hex(x) def __index__(self): 用于切片,数字无意义 x[y:z] <==> x[y.__index__():z.__index__()] def __init__(self, x, base=10): # known special case of int.__init__ 构造方法,执行 x = 123 或 x = int(10) 时,自动调用,暂时忽略
------------------------------------------------------------------- def __int__(self): 转换为整数 x.__int__() <==> int(x) def __invert__(self): x.__invert__() <==> ~x def __long__(self): 转换为长整数 x.__long__() <==> long(x) def __lshift__(self, y): x.__lshift__(y) <==> x<<y def __mod__(self, y): x.__mod__(y) <==> x%y def __mul__(self, y): x.__mul__(y) <==> x*y def __neg__(self): x.__neg__() <==> -x
-------------------------------------------- @staticmethod # known case of __new__ def __new__(S, *more): T.__new__(S, ...) -> a new object with type S, a subtype of T def __nonzero__(self): x.__nonzero__() <==> x != 0 def __oct__(self): 返回改值的八进制表示 x.__oct__() <==> oct(x) def __or__(self, y): x.__or__(y) <==> x|y def __pos__(self): x.__pos__() <==> +x """ def __pow__(self, y, z=None): 幂,次方 """ x.__pow__(y[, z]) <==> pow(x, y[, z]) def __radd__(self, y): x.__radd__(y) <==> y+x def __rand__(self, y): x.__rand__(y) <==> y&x def __rdivmod__(self, y): x.__rdivmod__(y) <==> divmod(y, x) def __rdiv__(self, y): x.__rdiv__(y) <==> y/x def __repr__(self): 转化为解释器可读取的形式 x.__repr__() <==> repr(x) def __str__(self): 转换为人阅读的形式,如果没有适于人阅读的解释形式的话,则返回解释器课阅读的形式 x.__str__() <==> str(x) def __rfloordiv__(self, y): x.__rfloordiv__(y) <==> y//x def __rlshift__(self, y): x.__rlshift__(y) <==> y<<x def __rmod__(self, y): x.__rmod__(y) <==> y%x def __rmul__(self, y): x.__rmul__(y) <==> y*x def __ror__(self, y): x.__ror__(y) <==> y|x def __rpow__(self, x, z=None): y.__rpow__(x[, z]) <==> pow(x, y[, z]) def __rrshift__(self, y): x.__rrshift__(y) <==> y>>x def __rshift__(self, y): x.__rshift__(y) <==> x>>y def __rsub__(self, y): x.__rsub__(y) <==> y-x """ def __rtruediv__(self, y): x.__rtruediv__(y) <==> y/x def __rxor__(self, y): x.__rxor__(y) <==> y^x def __sub__(self, y): x.__sub__(y) <==> x-y def __truediv__(self, y): x.__truediv__(y) <==> x/y def __trunc__(self, *args, **kwargs): 返回数值被截取为整形的值,在整形中无意义 def __xor__(self, y): x.__xor__(y) <==> x^
###########################
class long(object):
long(x=0) -> long
long(x, base=10) -> long
def bit_length(self):
long.bit_length() -> int or long
>>> bin(37L)
'0b100101'
>>> (37L).bit_length()
def __abs__(self):
x.__abs__() <==> abs(x)
def __add__(self, y):
x.__add__(y) <==> x+y
def __and__(self, y):
x.__and__(y) <==> x&y
def __cmp__(self, y):
x.__cmp__(y) <==> cmp(x,y)
def __coerce__(self, y):
x.__coerce__(y) <==> coerce(x, y)
def __divmod__(self, y):
x.__divmod__(y) <==> divmod(x, y)
def __div__(self, y):
x.__div__(y) <==> x/y
def __float__(self):
x.__float__() <==> float(x)
def __floordiv__(self, y):
x.__floordiv__(y) <==> x//y
def __format__(self, *args, **kwargs): # real signature unknown
def __getattribute__(self, name):
x.__getattribute__('name') <==> x.name
def __getnewargs__(self, *args, **kwargs): # real signature unknown
def __hash__(self):
x.__hash__() <==> hash(x)
def __hex__(self):
x.__hex__() <==> hex(x)
def __index__(self):
x[y:z] <==> x[y.__index__():z.__index__()]
def __init__(self, x=0):
def __int__(self):
x.__int__() <==> int(x)
def __invert__(self):
x.__invert__() <==> ~x
def __long__(self):
x.__long__() <==> long(x)
def __lshift__(self, y):
x.__lshift__(y) <==> x<<y
def __mod__(self, y):
x.__mod__(y) <==> x%y
def __mul__(self, y):
x.__mul__(y) <==> x*y
def __neg__(self):
x.__neg__() <==> -x
@staticmethod # known case of __new__
def __new__(S, *more):
T.__new__(S, ...) -> a new object with type S, a subtype of T
def __nonzero__(self):
x.__nonzero__() <==> x != 0
def __oct__(self):
x.__oct__() <==> oct(x)
def __or__(self, y):
x.__or__(y) <==> x|y
def __pos__(self):
x.__pos__() <==> +x
def __pow__(self, y, z=None):
x.__pow__(y[, z]) <==> pow(x, y[, z])
def __radd__(self, y):
x.__radd__(y) <==> y+x
def __rand__(self, y):
x.__rand__(y) <==> y&x
def __rdivmod__(self, y):
x.__rdivmod__(y) <==> divmod(y, x)
def __rdiv__(self, y):
x.__rdiv__(y) <==> y/x
def __repr__(self):
x.__repr__() <==> repr(x)
def __rfloordiv__(self, y):
x.__rfloordiv__(y) <==> y//x
def __rlshift__(self, y):
x.__rlshift__(y) <==> y<<x
def __rmod__(self, y):
x.__rmod__(y) <==> y%x
def __rmul__(self, y):
x.__rmul__(y) <==> y*x
def __ror__(self, y):
x.__ror__(y) <==> y|x
def __rpow__(self, x, z=None):
y.__rpow__(x[, z]) <==> pow(x, y[, z])
def __rrshift__(self, y):
x.__rrshift__(y) <==> y>>x
def __rshift__(self, y):
x.__rshift__(y) <==> x>>y
def __rsub__(self, y):
x.__rsub__(y) <==> y-x
def __rtruediv__(self, y):
x.__rtruediv__(y) <==> y/x
def __rxor__(self, y):
x.__rxor__(y) <==> y^x
def __sizeof__(self, *args, **kwargs): # real signature unknown
Returns size in memory, in bytes
def __str__(self):
x.__str__() <==> str(x)
def __sub__(self, y):
x.__sub__(y) <==> x-y
def __truediv__(self, y):
x.__truediv__(y) <==> x/y
def __trunc__(self, *args, **kwargs): # real signature unknown
Truncating an Integral returns itself.
def __xor__(self, y):
x.__xor__(y) <==> x^y
上一篇: 浮点型float
下一篇: 条件,循环
o
粉丝 0
博文 500
码字总数 0
作品 0
私信 提问
加载中
请先登录后再评论。

暂无文章

pycurl libcurl link-time ssl backend (nss)

pip uninstall pycurlecho 'pycurl==7.19.5.1 --global-option="--with-nss"' > requires.pypip install -r requires.py...

小红手
48分钟前
17
0
计算机网络性能衡量

1、速率 单位时间(s)内传输信息(bit)量 单位:KB/s, MB/s, Gb/s K = 10^3 ,M = 10^6, G=10^9 一般表示的是理想的传输速率 2、带宽 计算机网络中的带宽和通信等领域的带宽概念不一样,计算机网...

osc_np3y0rbq
48分钟前
3
0
互联网掀起农家乐,巨头上演AI掘金战

配图来自Canva **前有网易、阿里AI养猪,后有腾讯AI养鹅,互联网大佬们纷纷玩起了“农家乐”,互联网的生意在尖端技术的引领之下频频跨界,巨头之间的较量也从线上延伸至线下。**自古“民以食...

osc_5cok9i01
49分钟前
9
0
原来!我在4年前就开始体验雾游戏了!

前有云游戏后有雾游戏,游戏的方式看来起来越来越多种多样。那么“震撼业界”的雾游戏到底是什么来头?它依靠什么改变游戏界?它的原理又是什么? 本月月初,著名的日本游戏杂志《Fami通》表...

osc_j34n26zn
51分钟前
11
0
活动预告|田溯宁与你相约GSMA Thrive·万物生晖,分享5G风口下的创新与投资洞察

在万物互联的时代背景下,5G+AI+IoT的技术变革与融合,正在引发一场深刻的全产业创新与变革。5G技术创新、行业应用及投资机遇已成为科技行业所瞩目的焦点。 6月30日,宽带资本董事长田溯宁将...

osc_0qnrwmy3
52分钟前
7
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部