摘要: from datetime import date, datetime import numbers class IntField: #数据描述符,实现以下任意一个,都会变为属性描述符 def __get__(self, instance, owner): return self.value def __set__(self, instance, val... 阅读全文
posted @ 2018-04-18 18:51 Erick-LONG 阅读(204) 评论(0) 推荐(0) 编辑
摘要: #__getattr__, __getattribute__ #__getattr__ 就是在查找不到属性的时候调用 from datetime import date class User: def __init__(self,info={}): self.info = info def __getattr__(self, item): ret... 阅读全文
posted @ 2018-04-18 18:09 Erick-LONG 阅读(170) 评论(0) 推荐(0) 编辑
摘要: from datetime import date, datetime class User: def __init__(self, name, birthday): self.name = name self.birthday = birthday self._age = 0 # def get_age(self): #... 阅读全文
posted @ 2018-04-18 17:18 Erick-LONG 阅读(122) 评论(0) 推荐(0) 编辑