Discuss / Python / str2num 貌似可读性很差啊

str2num 貌似可读性很差啊

Topic source

from functools import reduce

def str2float(s): return (reduce(lambda x,y:x*10+y,#匿名函数生成int [int(x) for x in list(a) if x !='.'])#生成纯数列 /pow(10,len(a)-a.index('.')-1))#转化浮点数

str2float调用参数应该是a不是s写错了


  • 1

Reply