python笔记:匿名函数和闭包 1 匿名函数(lambda)很可惜,只能支持一行testFunc = lambda x,y: x+y print testFunc(1,1) #输出22 函数传递这真是太方便了。。testFunc = lambda x,y: x+y def Test(): print "hello" funcList = [Test,testFunc] funcList[0]() print funcList[1](2,2)3 内部函数def Test(): i = 10 def innerFunc(): print i,"hello" i=9 innerFunc() Test()内部函数中传入的参数,传的是引用,谨慎谨慎谨慎使用。最好是不用。 来自 大脸猫 写于 2016-05-17 14:52 -- 更新于2020-10-19 13:06 -- 0 条评论