题解 | #进制转换#
进制转换
https://www.nowcoder.com/practice/deb19498bc644f53a6a99905ef5ee01d
list1 = ["A", "B", "C", "D", "E", "F"] while True: try: tdata = input() rdata = tdata[2:] num = 0 for i in range(len(rdata)): if "A" <= rdata[i] <= "F": num += 16 ** (len(rdata) - i - 1) * (list1.index(rdata[i]) + 10) elif "0" <= rdata[i] <= "9": num += 16 ** (len(rdata) - i - 1) * (int(rdata[i])) print(num) except EOFError: break