Conversion between Python hex

Decimal converted to other binary:

# 10 → binary decimal

11 - > 1011
1011-> 8+2+1
print(bin(11)) # 0b1011

# 10 hex conversion into octal

print(oct(11)) # 0o13

# 10 hex convert hex

print(hex(11)) # 0xb
print(hex(123)) # 0xb

Other system converted into its decimal

Binary conversion to decimal

print(int('0b1011',2)) # 11

Binary conversion into octal

print(int('0o13',8)) # 11

Binary converted to hexadecimal

print(int('0xb',16)) # 11

 

Guess you like

Origin www.cnblogs.com/baicai37/p/12455788.html