[b]Python中的闭包[/b]
前几天又有人留言,关于其中一个[code]闭包[/code]和[code]re.sub[/code]的使用不太清楚。我在编程素材网搜索了下,发现没有写过闭包相关的东西,所以决定总结一下,完善Python的内容。
[b]1. 闭包的概念[/b]
首先还得从基本概念说起,什么是闭包呢?来看下维基上的解释:
[url=http://zh.wikipedia.org/wiki/%E9%97%AD%E5%8C%85_(%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%A7%91%E5%AD%A6)]维基百科-闭包[/url]
[url=http://stackoverflow.com/questions/4020419/closures-in-python]http://stackoverflow.com/questions/4020419/closures-in-python[/url]
[url=http://www.shutupandship.com/2012/01/python-closures-explained.html]http://www.shutupandship.com/2012/01/python-closures-explained.html[/url]
[url=http://stackoverflow.com/questions/141642/what-limitations-have-closures-in-python-compared-to-language-x-closures]http://stackoverflow.com/questions/141642/what-limitations-have-closures-in-python-compared-to-language-x-closures[/url]
[url=http://mrevelle.blogspot.com/2006/10/closure-on-closures.html]http://mrevelle.blogspot.com/2006/10/closure-on-closures.html[/url]