# # 把字符串转换成浮点数 # def str2float(S): def ch2int(ch): return {'0' : 0, '1' : 1, '2' : 2, '3' : 3, '4' : 4, '5' : 5, '6' : 6, '7' : 7, '8' : 8, '9' : 9}[ch] def str2int(s): return reduce(lambda x, y : x * 10 + y, map(ch2int, s)) ns = S.split('.') return str2int(ns[0]) + 0.1 ** len(ns[1]) * str2int(ns[1]) print(str2float('7432.00467'))
错了,第三题 ……
Sign in to make a reply
丿疯子乄