马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 xiaofan1228 于 2020-3-9 12:43 编辑 class Typed:
def __get__(self, instance,owner):
print('get方法')
print('instance参数【%s】' %instance)
print('owner参数【%s】' %owner)
def __set__(self, instance, value):
print('set方法')
print('instance参数【%s】' %instance)
print('value参数【%s】' %value)
def __delete__(self, instance):
print('delete方法')
print('instance参数【%s】'% instance)
class People:
name=Typed()
def __init__(self,name,age,salary):
self.name=name
self.age=age
self.salary=salary
p1=People('alex',13,13.3)
print(p1.__dict__) #这里输出
输出结果
{'age': 13, 'salary': 13.3}
问题: 为什么没有输出 name ? 另,求关于__dict__的拓展阅读 |