Discuss / Python / pow函数后面的0为什么那么多

pow函数后面的0为什么那么多

Topic source

def str2float(s): p = s.find('.'); l1 = s[:p] l2 = s[p+1:] return reduce(lambda x,y:x10+y,map(char2num,l1+l2)) pow(.1,len(l2))

def char2num(s): return {'0':0,'1':1,'2':2,'3':3,'4':4,'5':5,'6':6,'7':7,'8':8,'9':9,}[s]


  • 1

Reply