int方法
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了int方法相关的知识,希望对你有一定的参考价值。
代码
#int内部功能 name=‘Kamil.Liu‘ age=18 num=-11 print(dir(age)) print(age.bit_length())#返回表示当前数字占用的最少位数 print(num.__abs__())#__abs__:返回绝对值(或abs(-11)) print(age.__add__(num)) ‘‘‘ __add__:相加(+) __bool__:转换为布尔值 __divmod__:相除,得到商和余数组成的元祖 __and__:与运算 ‘‘‘ print(age.__eq__(18)) #__eq__: 等于(==) print(type(age.__float__())) #__float__:根据原有数据,创建新的浮点型数据 ‘‘‘ __floordiv__:地板除(//) __ge__:大于等于 __gt__:大于 __init__:构造方法 __pow__:幂运算 __init__:构造方法 ‘‘‘
结果
[‘__abs__‘, ‘__add__‘, ‘__and__‘, ‘__bool__‘, ‘__ceil__‘, ‘__class__‘, ‘__delattr__‘, ‘__dir__‘, ‘__divmod__‘, ‘__doc__‘, ‘__eq__‘, ‘__float__‘, ‘__floor__‘, ‘__floordiv__‘, ‘__format__‘, ‘__ge__‘, ‘__getattribute__‘, ‘__getnewargs__‘, ‘__gt__‘, ‘__hash__‘, ‘__index__‘, ‘__init__‘, ‘__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‘] 5 11 7 True <class ‘float‘>
以上是关于int方法的主要内容,如果未能解决你的问题,请参考以下文章
如何将这个 Objective-C 代码片段写入 Swift?
java.lang.NullPointerException: Attempt to invoke virtual method ‘int android.database.sqlite异常(代码片段