标签:turn class ace ret code span main def replace
def dec_hex(str1): #十转十六 a = str(hex(eval(str1))) b = a.replace("0x",‘‘) print(‘十进制 \t%s\t十六进制\t%s‘%(str1, a)) return b def hex_dec(str2): #十六转十 b = eval("0x" + str2) a = str(b).replace("0x",‘‘) print(‘十六进制\t%s\t十进制 \t%s‘%(str2, a)) return b if __name__ == ‘__main__‘: str1 = "16" # 十进制 str2 = "034" # 十六 print(dec_hex(str1)) print(hex_dec(str2))
标签:turn class ace ret code span main def replace
原文地址:https://www.cnblogs.com/fangbei/p/9802184.html