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

函数特点

时间:2018-05-23 16:15:15      阅读:100      评论:0      收藏:0      [点我收藏+]

标签:lambda   调用   cal   内存   def   print   int   回收   特点   

#def定义的非匿名函数,不会被立即回收
‘‘‘
def foo():
print("in the foo")
bar() #foo调用的时候,还未被被定义,所以报错

foo()
‘‘‘
def bar():
print("in the bar")

def foo():
print("in the foo")
bar() #已经被定义,所以不报错
foo()

#匿名函数,内存立即回收
calc = lambda x:x*3
calc(3) #等于9

函数特点

标签:lambda   调用   cal   内存   def   print   int   回收   特点   

原文地址:https://www.cnblogs.com/wzsx/p/9077226.html

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