Discuss / Python / 一行能写完的代码,就不要用两行了

一行能写完的代码,就不要用两行了

Topic source

kkopite

#1 Created at ... [Delete] [Delete and Lock User]
def str2float(s):
    return reduce(lambda x,y:10*x+y,map(int,s[:s.find('.')])) + reduce(lambda x,y:x/10 + y,(map(int,s[-1:s.find('.'):-1])))/10;

  • 1

Reply