![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
函数
xman4code
这个作者很懒,什么都没留下…
展开
-
Python学习笔记(5)--函数定义
Python学习笔记(5)–函数定义 函数可以自定义,且自定义其中的报错信息 def my_abs(x): if not isinstance(x, (int, float)): raise TypeError('bad operand type') if x >= 0: return x else: retur...原创 2018-05-08 17:02:59 · 150 阅读 · 0 评论 -
Python学习笔记(8) ---- map函数+reduce函数+filter函数+sorted()函数
在python中内置了一种函数:map函数。map函数接受两个参数(函数,Iterator)返回值为另一个Iterator。 函数可以把参数Iterator中的每一个元素通过参数中的函数进行计算,把返回值作为一个新的Iterator整体返回。 def f(x): return x * x r = map(f, [1, 2, 3, 4, 5, 6, 7, 8, 9]) list(r)...原创 2018-06-19 21:55:34 · 153 阅读 · 0 评论