python 进制转换
设10进制数字为20
10转2:bin(20) 0b10100
10转8:oct(20) 0o24
10转16:hex(20) 0x14
2转10:int("0b10100",2)
8转10:int("0o24",8)
16转10:int("0x14",16)
l2 = []
l8 = []
l16 = []
n = 20
for i in range(n):
l2.append(bin(i))
l8.append(oct(i))
l16.append(hex(i))
print(l2)
print(l8)
print(l16)
for i in range(n):
print(int(l2[i],2), end=" ")
print(int(l8[i], 8), end=" ")
print(int(l16[i], 16))