概述
python有六大数据类型,分别为整型、字符串、列表、字典、元祖和集合,这些基本数据类型都内置了很多方法,接下来一一探寻。
python中整型有两种:int和float
<span style="color: #008000">#<span style="color: #008000"> python 2.x
<span style="color: #000000">dir(int)
<span style="color: #008000">#<span style="color: #008000"> ['abs','cmp','coerce','div','float','hash','hex','int','long','neg','nonzero','oct','pos','rdiv','repr','rlshift','rsub','setattr','xor','denominator','real']
因为是整型类型,所以有加减乘除、取绝对值的方法,像__abs__是取绝对值,__add__是加法等,其中重要的几个方法是:bit_length、conjugate、from_bytes、imag、numerator、real、to_bytes
如果您也喜欢它,动动您的小指点个赞吧