Discuss / Python / 第三题

第三题

Topic source

WALL_E91

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

def str2float(s):

# 这里只能这样用才能把list或者字符串变成键值对才能这样应用for循环
for n,p in enumerate(s):
    if p == ".":
        n1 = n
    print(n, p)
def a(x, y):
    return x * 10 + y
n2 = n1 + 1
num = len(s[n2:])
return reduce(a ,map(int, s[:n1])) + reduce(a, map(int, s[n2:])) / (10**num)

  • 1

Reply