Binary 0b101 uses numbers 0 and B to indicate binary numbers. if a number greater than or equal to 2 is displayed, SyntaxError is thrown. octal 0711 indicates the number of octal numbers.
Different hexadecimal
Binary 0b101
If a number greater than or equal to 2 is displayed, a SyntaxError error is thrown.
Octal 0711
If a number greater than or equal to 8 is displayed, a SyntaxError error is thrown.
Decimal 123
Letters are not allowed for normal display
Hexadecimal 0x15
If the hexadecimal number is indicated by the number 0 and subtitle x headers, other values 0-9, abcdef, and ABCDEF may cause a SyntaxError error.
Built-in functions after python 2.6
# Convert from 10 to 2
>>> bin(10)'0b1010'
# Convert from 2 to 10
>>> int("1001",2)9
# Convert from 10 to 16
>>> hex(10)'0xa'
# Hexadecimal to hexadecimal
>>> int('ff', 16)255
>>> int('0xab', 16)171
# Convert decimal to octal
>>print("%o" % 10)>>12
# Hexadecimal to binary
>>> bin(0xa)'0b1010'>>>
#10 to 8
>>> oct(8)'010'
# Binary to hexadecimal
>>> hex(0b1001)'0x9'
In addition, in the interactive interpreter environment, python automatically converts different hexadecimal values to decimal values for calculation.
>>> 0b101 + 0711 + 123 + 0x15 606