Discuss / Python / 不知道为什么发出来格式不对

不知道为什么发出来格式不对

Topic source

IE洗铁路

#1 Created at ... [Delete] [Delete and Lock User]
# -*- coding: utf-8 -*-from functools import reducedef str2float(s):    s = str(s)    DIGITS={'1':1,'2':2,'3':3,'4':4,'5':5,'6':6,'7':7,'8':8,'9':9}    def input2digit(s):        return DIGITS[s]    i = s.index('.')    s1 = s[:i]    s2 = s[i+1:]    def fn1(x,y):        return x * 10 + y    r1=reduce(fn1,map(input2digit,s1))    r2=reduce(fn1,map(input2digit,s2))*0.1**len(s2)    return r1+r2

  • 1

Reply