def str2float(s):
DIGITS = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9,'.':'.'}
sList = s.split('.')
def str2list(index):
return DIGITS[index]
def frontDotF(x,y):
return x * 10 + y
frontDot = list(map(str2list,sList[0]))
behindDot = list(map(str2list,sList[1]))
s1 = reduce(frontDotF,frontDot)
s2 = reduce(frontDotF,behindDot)/10**len(behindDot)
return s1 + s2
Sign in to make a reply
a_XXX_XXX_a
def str2float(s):
DIGITS = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9,'.':'.'}
sList = s.split('.')
def str2list(index):
return DIGITS[index]
def frontDotF(x,y):
return x * 10 + y
frontDot = list(map(str2list,sList[0]))
behindDot = list(map(str2list,sList[1]))
s1 = reduce(frontDotF,frontDot)
s2 = reduce(frontDotF,behindDot)/10**len(behindDot)
return s1 + s2