摘要: import threading import time class Foo: _instance = None _lock = threading.RLOCK() def __new__(cls,*args,**kwargs): if cls._instance: return cls._instance ... 阅读全文
posted @ 2019-01-04 10:35 显示名称已经被使用 阅读(137) 评论(0) 推荐(0) 编辑
摘要: 我们知道,python中装饰器无非是对对象的重新包装,这个对象可以是函数,也可以是一个类 @decoratedef test():相当于 test = decorate(test) def decorate(func): def wrap(*args,**kwargs): ***** return 阅读全文
posted @ 2019-01-04 10:34 显示名称已经被使用 阅读(405) 评论(0) 推荐(0) 编辑
摘要: 通过一个内嵌类 "class Meta" 给你的 model 定义元数据, 类似下面这样: class Foo(models.Model): bar = models.CharField(maxlength=30) class Meta: # ... Model 元数据就是 "不是一个字段的任何数据 阅读全文
posted @ 2019-01-04 10:23 显示名称已经被使用 阅读(217) 评论(0) 推荐(0) 编辑