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'>

 

转载于:https://www.cnblogs.com/kamil/p/5160866.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值