class Product():
def __init__(self,name):
self.name = name
self.label_price = 0
self.real_price = 0
c = Product("Computer")
d = Product("Printer")
e = Product("Projector")
c.label_price,c.real_price = 10000,8000
d.label_price,d.real_price = 2000,1000
e.label_price,e.real_price = 1500,900
s1,s2 = 0,0
for i in [c,d,e]:
s1 += i.label_price
s2 += i.real_price
print(s1,s2)
嵩天老师Python面向对象-1, Python面向对象编程模式
猜你喜欢
转载自blog.csdn.net/f2157120/article/details/105566609
周排行