67

Python入门篇(七)之装饰器-勿忘初心

 6 years ago
source link: http://blog.51cto.com/jinlong/2083160
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
1、装饰器1.1、装饰器定义装饰器:定义:本质上是函数,(装饰器的功能:装饰其他函数),就是为其他函数添加附加的功能。原则:1.不能修改被装饰的函数的源代码2.不能修改被装饰的函数的调用方式简单装饰器程序演示:计算test1函数的运行时间importtimedeftimemer(func):#使用高阶函数定义装饰器defwarpper(*args,**kwargs):#装饰器的函数,函数体为装饰器

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK