整型int和长整型long

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
posted @ 2018-08-06 21:17  Sky-wings  阅读(4590)  评论(0编辑  收藏  举报