题解 | #进制转换#python 使用字典
进制转换
http://www.nowcoder.com/practice/8f3df50d2b9043208c5eed283d1d4da6
while 1:
try:
string = '0123456789ABCDEF'
string_dict = {}
for i , j in enumerate(string):
string_dict[j] = i
aim_num = input().lstrip("0x")
change_num = 0
for i in range(len(aim_num)):
change_num += string_dict[aim_num[i]](16*(len(aim_num) -i - 1))
print(change_num)
except:
break
查看11道真题和解析