#解法1,搞一个16进制数转换到10进制的表,逐位转换 #import sys map_v = {'0': 0, '1':1, '2': 2, '3':3, '4': 4, '5':5, '6': 6, '7':7, '8': 8, '9':9, 'A': 10, 'B':11, 'C': 12, 'D':13, 'E': 14, 'F':15} while True: try: x_str = input() x_str = x_str[2:] value = 0 for c in x_str: value = map_v[c] + value * 16 #每次循环相当于之前的左移,高位乘16 print(value) except: #print(sys.exc_info()) break # #解法2 # while True: # try: # print(int(input(),16)) # except: # break