第三题
Topic source更正错误之后的
import math
from functools import reduce
def str1num(x1,x2):
if x2==-1:
return x1
return x1*10+x2
def str2num(x):
return {'0':0,'1':1,'2':2,'3':3,'4':4,'5':5,'6':6,'7':7,'8':8,'9':9,'0':0,'.':-1}[x]
def change(L):
m=len(L)-L.find('.')-1
if m>=len(L):
return reduce(str1num,map(str2num,L))
return (reduce(str1num,map(str2num,L)))/math.pow(10,m)
print(change('324.24089'))
- 1
王饮刀