Discuss / Python / 第三题没有各位大佬的那么复杂,感觉自己写的好简单qwq

第三题没有各位大佬的那么复杂,感觉自己写的好简单qwq

Topic source

吼kk

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

from functools import reduce

def str2float(s): 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] def fn(x,y): return x 10 + y L = list(s) for i in range(len(L)): if L[-i] == '.': L.pop(-i) num1 = reduce(fn,map(char2num,L)) num2 = num1/10*(i-1) print(num2) str2float('112.32')

吼kk

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

发错了,,各位大佬不要介意

这是后面的题


  • 1

Reply