Discuss / Python / 在简单的代码也要亲手敲一遍

在简单的代码也要亲手敲一遍

Topic source

翁岚敏

#1 Created at ... [Delete] [Delete and Lock User]

from functools import reduce def str2float(s): a=len(s)-s.find('.')-1 s=s.replace('.','') return reduce(lambda x,y:x10+y,map(int,s))/10*a print('str2float(\'123.456\')=',str2float('123.456'))


  • 1

Reply