摘要:
一、使用装饰器可以提高重用性,使用缓存可以提高执行效率 二、实现实例: def outter(func): cache = {} def inner(*args): if cache.get(args): res = cache.get(args) return res res = cache[ar 阅读全文
posted @ 2021-06-01 10:57
只管去做-王炸
阅读(117)
评论(0)
推荐(0)
摘要:
一、装饰器是一种特殊的闭包函数,内部函数引用外部函数中的变量或者函数,形成闭包 二、装饰器实例: from functools import wrapsdef outter(func): ####调用func.__name__ 和func.__doc__时打印的是被装饰函数而不是inner @wra 阅读全文
posted @ 2021-06-01 10:42
只管去做-王炸
阅读(80)
评论(0)
推荐(0)
摘要:
一、可迭代对象基于islice方法实现切片操作 二、islice实现实例: print(list(islice(range(1, 10), 2, 7, 2))) 三、自定义切片方法实现实例: def my_islice(iterable, start, end, step=1): tmp = 0 f 阅读全文
posted @ 2021-06-01 08:56
只管去做-王炸
阅读(55)
评论(0)
推荐(0)
浙公网安备 33010602011771号