Python实战之int学习笔记及简单练习
['__abs__', '__add__', '__and__', '__bool__', '__ceil__', '__class__', '__delattr__', '__dir__', '__divmod__', '__doc__', '__eq__', '__float__', '__floor__', '__floordiv__', '__format__', '__ge__', '__getattribute__', '__getnewargs__', '__gt__', '__hash__', '__index__', '__init__', '__init_subclass__', '__int__', '__invert__', '__le__', '__lshift__', '__lt__', '__mod__', '__mul__', '__ne__', '__neg__', '__new__', '__or__', '__pos__', '__pow__', '__radd__', '__rand__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__', '__rfloordiv__', '__rlshift__', '__rmod__', '__rmul__', '__ror__', '__round__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__setattr__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', '__truediv__', '__trunc__', '__xor__', 'bit_length', 'conjugate', 'denominator', 'from_bytes', 'imag', 'numerator', 'real', 'to_bytes']
def __repr__(self): """转化为解释器可读取的形式 """ """ x.__repr__() <==> repr(x) """ pass def __str__(self): """转换为人阅读的形式,如果没有适于人阅读的解释形式的话,则返回解释器课阅读的形式""" """ x.__str__() <==> str(x) """ pass def __trunc__(self, *args, **kwargs): """ 返回数值被截取为整形的值,在整形中无意义 """ pass num = 37 nu2 = -10 # print(dir(num)) # print(num.bit_length()) # 6 # print(bin(num)) # 0b100101 # print(num.conjugate()) # 37 # print(nu2.__abs__()) # 10 # print(abs(nu2)) # 10 # print(num.__add__(nu2)) # 27 # print(num + nu2) # 27 # print(num.__and__(nu2)) # 36 # print(num&nu2) # 36 """ 相除,得到商和余数组成的元组 """ # print(num.__divmod__(nu2)) # (-4, -3) # print(divmod(num,nu2)) # (-4, -3) x = 12 y = -5 # print(x/y) # -2.4 # # print(x.__float__()) # print(float(x)) # 12.0 # print(x.__floordiv__(y)) # print(x//y) # -3 # print(x.__hash__()) # print(hash(x)) # 12 # print(x.__invert__()) # -13 # print(~x) # print(x.__lshift__(1)) # print(x<<1) # 24 # print(x.__mod__(y)) # print(x%y) # -3 # print(x.__mul__(y)) # print(x*y) # -60 # print(x.__neg__()) # print(-x) # -12 # print(x != 0) # True # print(x.__or__(y)) # print(x | y) # -1 # print(x.__pos__()) # print(+x) # 12 # print(x.__pow__(y)) # print(pow(x,y)) # 4.018775720164609e-06 # print(x.__radd__(y)) # print(y + x) # 7 # print(x.__rand__(y)) # print(y&x) # 8 print(x,y) # print(x.__rdivmod__(y)) # print(divmod(y,x)) # (-1,7) # print(x.__repr__()) # print(repr(x)) # print(x.__str__()) # print(str(x)) # 12 print(x.__trunc__())
posted on 2017-07-02 11:09 William126 阅读(185) 评论(0) 编辑 收藏 举报