Discuss / Python / 第三题

第三题

Topic source

llillz

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

def str2(s): return (reduce(lambda x,y:x*10+y, map(str_int, s.replace('.',''))) / pow(10,len(s)-1-s.find('.')) )

注:str_int函数就是从字典中提取字符对应整数的那个函数(我在自己机器上重命名了下) 程序的思路就是先去掉小数点,得到整数再做除法。没精简过代码,只提供一个思路。


  • 1

Reply