1 import re
 2 from functools import reduce
 3 
 4 s = '1546.322222'
 5 def ss(x):
 6     sss = s.split('.')
 7     return sss[x]
 8 
 9 def str2num(x):    
10     return int(x)
11 
12 
13 def m():
14     L10 = list(map(str2num,ss(0)))
15     L01 = list(map(str2num,ss(1)))
16     L = reduce(lambda x,y:x*10+y,L10)+reduce(lambda x,y:x*10+y,L01)*0.1**len(L01)
17     return L
18 
19 print(m())

关键是点的判断,用了re。

posted on 2017-10-25 13:53  Akinero  阅读(203)  评论(0编辑  收藏  举报