进制转换相关
bin,将十进制转化成二进制
num = 13
v1 = bin(num)
print(v1)
oct,将十进制转换成八进制
num = 8
v1 = oct(num)
print(v1)
int,将其他进制转化成十进制
# 二进制转化成十进制
v1 = '0b1101'
result = int(v1,base=2)
print(result)
# 八进制转化成十进制
v1 = '0o1101'
result = int(v1,base=8)
print(result)
# 十六进制转化成十进制
v1 = '0x1101'
result = int(v1,base=16)
print(result)
hex,将十进制转换成十六进制
num = 16
v1 = hex(num)
print(v1)
标签:转换,进制,int,18,v1,num,result,print,十进制
From: https://www.cnblogs.com/jhchena/p/18432497