
python的基础函数
Clytzecho
数据女一枚
展开
-
lambda() 匿名函数
lambda()是python对函数的一种简单表达当一个函数只用一次,又比较简单,没有必要另外定义的时候,可以用lambda(),使得程序更简洁.for example:1、def square(): return x**2map(square, [1, 2, 3, 4, 5])2、map(lambda x : x**2, [1, 2, 3, 4,5])...原创 2018-06-07 11:25:51 · 176 阅读 · 0 评论 -
reduce() : function for python
1、reduce() general form: reduce(f(), list[], int); A. f() must has two parameter。eg: f(x+y): x+y; f(x*y): x*y; B. list[] take the parameter C. int is not n...原创 2018-06-07 11:18:51 · 163 阅读 · 0 评论 -
python中的map()和reduce()
map()的标准格式:map(f(), list[])map()的返回格式:list()reduce()的标准格式: reduce(f(), list[])reduce()的返回格式: 对list()进行累算原创 2018-06-07 15:33:46 · 179 阅读 · 0 评论 -
python的可迭代对象
for … in … 适用于可迭代对象中,可迭代对象从集合的第一个元素开始访问,直到所有的元素被访问完结束。可迭代的对象需要一个特殊的声明,例如:这样来看,list、tuple、str都是在定义的时候有声明过这个__iter__,这样就直接使用了。在自己构造的时候,记得这一点即可。...原创 2018-06-07 15:58:44 · 208 阅读 · 0 评论 -
python的split函数
#python中不存在单个字符的运算,只有字符串函数>>> s="www.google.com">>> s'www.google.com'>>> s.split('.') #无参数全部切割['www', 'google', 'com'] #split之后是列表类型>>> s转载 2018-08-02 10:42:28 · 593 阅读 · 0 评论