Python.装饰器
来源:互联网 发布:mac系统格式化u盘 编辑:程序博客网 时间:2024/06/05 19:24
import time
def decorator(func):
def wrapper(*args,**kw):
print(time.time())
func(*args,**kw)
return wrapper
@decorator
def f1(func_name):
print("this is a function "+func_name)
@decorator
def f2(func_name,func_name2):
print("this is a function "+func_name)
print("this is a function "+func_name2)
@decorator
def f3(func_name,func_name2, **kw):
print("this is a function "+func_name)
print("this is a function "+func_name2)
print(kw)
f1('test func')
f2('test func','test func2')
f3('test func','test func2',a=1,b=2,c='123')
1512463591.4760053
this is a function test func
1512463591.4770052
this is a function test func
this is a function test func2
1512463591.4770052
this is a function test func
this is a function test func2
{'a': 1, 'b': 2, 'c': '123'}
this is a function test func
1512463591.4770052
this is a function test func
this is a function test func2
1512463591.4770052
this is a function test func
this is a function test func2
{'a': 1, 'b': 2, 'c': '123'}
阅读全文
0 0
- python装饰器装饰类
- [python]python装饰器
- Python装饰器学习
- Python装饰器
- python 装饰器
- Python装饰器
- python 装饰器 应用
- python 装饰器2
- Python装饰器学习
- python装饰器
- python装饰器
- python 装饰器入门
- python装饰器
- python装饰器
- python 装饰器'@'
- python装饰器
- Python装饰器详解
- python 装饰器
- [Leetcode] 495. Teemo Attacking 解题报告
- css/jquery 笑脸评价
- angular.foreach 的使用方法
- 微信浏览器调起相机拍照并显示图片
- form表单序列化转json(后台接收json转object)
- Python.装饰器
- 守护进线程,互斥锁,信号量,队列,死锁递归锁等
- 限制input输入类型(多种方法实现)
- unity-xcode 预编译
- Java技巧: 根据网址查询DNS/IP地址
- 2017年11月编程语言排行榜
- 蓝桥杯 动态数组的使用
- VUE(二)
- valgrind的编译和使用