原型模式
from copy import copy, deepcopy class Resume(object): def __init__(self,name): self.Name = name def person_info(self,sex,age): self.Sex = sex self.Age = age def work_experience(self,timeArea, company): self.TimeArea = timeArea self.Company = company def display(self): print(self.Name,self.Sex,self.Age,self.TimeArea,self.Company) def clone(self): return copy(self) def deep_cpoy(self): return deepcopy(self) f1 = Resume("韩") f1.person_info("男",23) f1.work_experience("90-96","xxx") f2 = f1.clone() f2.Name = "李" f2.person_info("女",20) f2.work_experience("93-97","ggg") f2.display() f1.display() 返回: 李 女 20 93-97 ggg 韩 男 23 90-96 xxx 原型模式