摘要:
from datetime import date, datetime import numbers class IntField: #数据描述符,实现以下任意一个,都会变为属性描述符 def __get__(self, instance, owner): return self.value def __set__(self, instance, val... 阅读全文
摘要:
#__getattr__, __getattribute__ #__getattr__ 就是在查找不到属性的时候调用 from datetime import date class User: def __init__(self,info={}): self.info = info def __getattr__(self, item): ret... 阅读全文
摘要:
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): #... 阅读全文