Different binary
Binary 0b101
A binary number that starts with the number 0 and the letter B will throw a SyntaxError exception if a number greater than or equal to 2 appears
Octal 0711
Numbers preceded by number 0 indicate octal numbers if a number greater than or equal to 8 throws a SyntaxError exception
Decimal 123
Normal display cannot appear letter
Hex 0x15
The hexadecimal number that begins with the number 0 and subtitle x can occur when 0-9 and abcdef or abcdef other values throw a SyntaxError exception
Python built-in functions after 2.6
#10进制转为2进制
>>> Bin (Ten) ' 0b1010 '
#2进制转为10进制
>>> Int ("1001", 2) 9
#10进制转为16进制
>>> Hex ' 0xa '
#16进制到10进制
>>> int (' FF ', 16) 255
>>> int (' 0xAB ', 16) 171
#十进制转为八进制
>>print ("%o"%) >>12
#16进制到2进制
>>> bin (0xa) ' 0b1010 ' >>>
#10进制到8进制
>>> Oct (8) ' 010 '
#2进制到16进制
>>> Hex (0b1001) ' 0x9 '
In addition, in an interactive interpreter environment. Python automatically converts the different binaries to decimal.
>>> 0b101 + 0711 + 123 + 0x15 606