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'