2012年9月11日

python--装饰器

摘要: 装饰器:对函数的包装1--被装饰的函数不带参数#"""无参数调用decorator声明时必须有一个参数,这个参数将接收要装饰的方法"""def deco(func):#deco对func进行包装... print 'start'... func()... print 'end'... return func... >>> @deco... def my():... print 'is my'... startis myend#注意:当使用上述方法定义一个decorato 阅读全文

posted @ 2012-09-11 11:47 龙沙宝石 阅读(365) 评论(0) 推荐(1) 编辑

导航