利用map和reduce编写一个str2float函数,把字符串'123.456'转换成浮点数123.456:
# -*- coding: utf-8 -*-
from functools import reduce
def str2float(s):
def fnzs(x,y):
return x*10+y;
n = s.index('.');
s1 = list(map(int,s[:n]));
s2 = list(map(int,s[n+1:]));...
原创
2018-11-24 22:41:09 ·
506 阅读 ·
0 评论