码迷,mamicode.com
首页 > 其他好文 > 详细

高阶函数

时间:2018-04-22 22:03:29      阅读:192      评论:0      收藏:0      [点我收藏+]

标签:bin   print   class   env   color   pre   code   encoding   style   

把函数作为参数传入,这样的函数称为高阶函数

如下:

 1 #!/usr/bin/env python
 2 #encoding:utf-8
 3 #by i3ekr
 4 
 5 import time
 6 def bar():
 7     print "the bar..."
 8 
 9 def func(cs):
10     start_time = time.time()
11     cs()
12     ent_time = time.time()
13     print("the fun run time is %s"%(ent_time - start_time))
14 
15 func(bar)

 

高阶函数

标签:bin   print   class   env   color   pre   code   encoding   style   

原文地址:https://www.cnblogs.com/nul1/p/8909148.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!