自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(6)
  • 收藏
  • 关注

原创 reduce函数

小练习num_1=[1,2,3,100]def reduce_test(func,array,init=None): if init is None: res = array.pop(0) else: res=init for num in array: res=func(res,num) return(res)...

2019-11-27 12:33:49 226

原创 filter函数

小练习movie_people=['sb_alex','sb_wupeiqi','lihaifeng']# def sb_show(n):# return n.startswith('sb')def filter_test(func,array): ret=[] for p in array: if not func(p): ...

2019-11-27 11:00:41 1037

原创 map函数

小练习num_1=[1,2,3,4,5]res=[]for i in num_1: res.append(i**2)print(res)#输出[1, 4, 9, 16, 25]num_1=[1,2,3,4,5]def add_1(x): return x+1def reduce_1(x): return x-1def map_test(func,a...

2019-11-20 21:21:58 294

原创 函数式编程

编程的方法论:面向过程:把一个大问题分解成若干小问题去解决def cal(x): res=2*x res+=1 return res函数式编程:函数式=编程语言定义的函数+数学意义的函数,python不是完全意义上的函数式编程,了解即可def cal(x): return 2*x+1面向对象注意:一定要区别这两个def calc(x): r...

2019-11-19 17:38:53 197

原创 匿名函数lambda

匿名函数fuc=lambda x:x+1a=fuc(10)print(a)def change_name(name): res=name+'_sb' return resprint(change_name('alex'))fuc=lambda name:name+'_sb' #自动returna=fuc('alex')print(a)#输出11alex_s...

2019-11-18 21:51:04 70

原创 函数的作用域

函数的作用域def test1(): print('in the test1')def test(): print('in the test') return 1res=test()print(res)in the test1def test1(): print('in the test1')def test(): print('in t...

2019-11-18 16:26:15 96

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除