Discuss / Python / 给出的解法仅供参考

给出的解法仅供参考

Topic source

#111

def normalize(name): return name.capitalize()

#222 from functools import reduce

def prod(L): return reduce((lambda x, y:x * y), L)

#333 from functools import reduce

def str2float(s): l = [int(x) for x in s if x.isdigit()] #str.isdigit是判断字符串是否为数字 return (reduce(lambda x, y: x*10 +y, l)) / (10 ** len((s.split('.'))[1]))

#ps 同学们可能都有一个疑问,自己写的代码复制过来 **就没了,这个回答框其实类似于一个python环境,听说过jupyter notebook的应该懂这个意思。解决方案就是在*号前加 \ 非转义就好了

守候986

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

高人!会持续关注你。。。。。。


  • 1

Reply