码迷,mamicode.com
首页 >  
搜索关键字:装饰器    ( 4200个结果
通用装饰器
通用装饰器 def wrapper(fun): def inner(*args,**kwargs): print(f"before execute target {fun} ") ret=fun() print(f"after execute target {fun}") return ret re ...
分类:其他好文   时间:2021-06-02 12:04:33    阅读次数:0
5.19Java装饰器设计模式
5.19Java装饰器设计模式 之前我们所说的都是节点流,Java当中的节点流就是直接与数据源交互的程序。为了提升性能、操作方便需要进行装饰处理 设计模式浅谈 高内聚,低耦合 >常见的设计模式有:单例、工厂、装饰、代理... 组织代码的固定模式和套路 >固定类、方法等设计 设计方法 抽象组件 >相当 ...
分类:编程语言   时间:2021-05-24 16:45:36    阅读次数:0
9 django CBV
1 修改views import hashlib import json from django.core import serializers from django.http import JsonResponse from django.utils.decorators import meth ...
分类:其他好文   时间:2021-05-24 16:10:13    阅读次数:0
Pytest-parametrize参数化
对于一些场景需要大量数据来支撑的测试,就可以用到参数化来节省手工测试所花费的时间 pytest参数化需要用到装饰器:parametrize 用户,导入pytest模块之后,在函数上方使用,效果如下: import pytest @pytest.mark.parametrize("id,goodsco ...
分类:其他好文   时间:2021-05-24 13:16:38    阅读次数:0
Pytest测试框架(3)--参数设置、丰富的第三方插件 实现自定义执行
1。 调整用例执行顺序 默认按名称顺序执行。安装pip install pytest-ordering, 在测试方法上加装饰器@pytest.mark.last @pytest.mark.run(order=1) 2。遇到错误停止执行 -x 参数 pytest -x -v -s test_01.py ...
分类:其他好文   时间:2021-05-24 00:48:43    阅读次数:0
Python----闭包和装饰器
# 闭包 def outer(x): print('outer:',x) def inner(): print('inner:', x) return inner # 外部函数return的一定是内部函数的函数名 def a(x): print('a:',x) def b(y): print('b: ...
分类:编程语言   时间:2021-05-04 16:12:49    阅读次数:0
@property 的用法
类/装饰器 @property装饰器负责把类中的方法转换成属性来调用 有三种调用方法 方法一:@property直接加在需要转换的方法上 class People: def __init__(self, name, weight, height): self.__name = name self.w ...
分类:其他好文   时间:2021-04-13 12:41:12    阅读次数:0
(七)注册Flask命令(使用click模块)
1.添加装饰器 @app.cli.command() def hello(): click.echo('Hello, Human!click Fun.') 注册了flask命令:即函数名:hello,执行:flask hello 来触发执行 传入自定义命令:@app.cli.command('abc ...
分类:其他好文   时间:2021-03-29 12:32:45    阅读次数:0
装饰器
装饰器 定义:是在不改变函数的调用方式,还能为此函数前后添加功能 装饰器的形成过程 一、写一个测试代码时间的函数 import time#导入time模块是为了模拟函数运行时间 def inner(): start=time.time() time.sleep(1) for i in range(1 ...
分类:其他好文   时间:2021-03-29 11:52:53    阅读次数:0
python中一些常用的方法和技巧(自己不会的)
python内置的装饰器property的使用: property这个装饰器一般使用在类中,我们可以用@property装饰器来创建只读属性,@property装饰器会将装饰的方法转换为相同名称的只读属性,可以与所定义的属性配合使用,这样可以防止属性被修改。 使用场景: 在类中修饰方法,使得方法可以 ...
分类:编程语言   时间:2021-03-11 11:43:47    阅读次数:0
4200条   上一页 1 2 3 4 5 ... 420 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!