“”“单例模式”“”


“”“工厂模式”“”
class Person:
pass
class Worker(Person):
pass
class Student(Person):
pass
class Teacher(Person):
pass
class Factory:
def get_person(self, p_type):
if p_type == 'w':
return Worker()
elif p_type == 's':
return Student()
else:
return Teacher()
pf = Factory()
worker = pf.get_person('w')
stu = pf.get_person('s')
teacher = pf.get_person('t')
















![P1118 [USACO06FEB] Backward Digit Sums G/S(dfs+思维杨辉三角)](https://img-blog.csdnimg.cn/78163affc9124232917d324d4e8a873f.png)

