bin(x) 转换二进制

bin(x)

Convert an integer number to a binary string prefixed with “0b”. 
转换一个整型数字为一个前缀是“0b”的二进制字符串
If x is not a Python int object, it has to define an __index__() method that returns an integer. 
若是x不是 int 对象,必须定义一个返回整型的__index__() 方法
>>> bin(3)
'0b11'
>>> bin(-10)
'-0b1010'
相关文章
相关标签/搜索