利用map和reduce编写一个str2float函数,把字符串‘123.456‘转换成浮点数123.456:
from functools import reducedef str2float(s): DIGITS = { '0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9 } def char2num(s): .
转载
2021-11-19 13:15:59 ·
331 阅读 ·
0 评论