python binary, octal, hexadecimal

python and normal display operation is a decimal number.


A, python binary

bin () function to convert decimal to binary, binary prefix 0B. Such as:

>>> bin(10)
'0b1010'

 

Two, python in octal

oct () function to convert a decimal to octal, 0o octal prefix. Such as:

>>> oct(10)
'0o12'

 

Three, python hexadecimal

hex () function to convert decimal to hexadecimal, prefix 0x are hexadecimal. Such as:

>>> hex(95)
'0x5f'

 

Guess you like

Origin www.cnblogs.com/relex/p/10956611.html