摘要: 一切的类都是通过type这个类来创建的,例如: 1 class Foo: 2 a = 1 3 pass 4 5 6 print(type(Foo)) 7 print(Foo.__dict__) 8 9 10 def __init__(self, name, age): 11 self.name = 阅读全文
posted @ 2020-03-16 21:05 竹石2020 阅读(94) 评论(0) 推荐(0)
摘要: 1 class Goods: 2 def __init__(self,price,discount): 3 self.price = price 4 self.discount = discount 5 6 @property 7 def price1(self): 8 return self.pr 阅读全文
posted @ 2020-03-16 15:40 竹石2020 阅读(136) 评论(0) 推荐(0)
摘要: 1 class property2: 2 def __init__(self, func): 3 print('执行property2') 4 self.func = func 5 6 def __get__(self, instance, owner): 7 print('执行get') 8 se 阅读全文
posted @ 2020-03-16 15:29 竹石2020 阅读(189) 评论(0) 推荐(0)
摘要: 1 class property2: 2 def __init__(self, func): 3 print('执行property2') 4 self.func = func 5 6 def __get__(self, instance, owner): 7 return self.func(in 阅读全文
posted @ 2020-03-16 12:19 竹石2020 阅读(133) 评论(0) 推荐(0)
摘要: 1 class Type: 2 def __init__(self, key, expcet_type): 3 self.key = key 4 self.expct_type = expcet_type 5 6 def __get__(self, instance, owner): 7 print 阅读全文
posted @ 2020-03-16 10:32 竹石2020 阅读(156) 评论(0) 推荐(0)