摘要:
工厂函数看上去有点像函数,实质上他们是类,当你调用它们时,实际上是生成了该类型的一个实例,就像工厂生产货物一样。 阅读全文
摘要:
class DataSet(object): def __init__(self): self._images = 1 self._labels = 2 #定义属性的名称 @property def images(self): #方法加入@property后,这个方法相当于一个属性,这个属性可以让用 阅读全文
摘要:
@property --> 装饰器,创建只读属性 @property + 方法 --> 方法变为只读属性,防止属性被修改; class DataSet(object): @property def method_with_property(self): ##含有@property return 15 阅读全文