英文文档: delattr(object, name) This is a relative of setattr(). The arguments are an object and a string. The string must be the name of one of the object’s attributes. The function deletes the named attribute, provided the object allows it. For example…
不急着进入正题.先动手完成一个小程序: 设计一套简单的服务开启关闭程序,每次开启或关闭都得打印服务当前的状态: class Server(object): def __init__(self): self.status='stop' #初始状态 def start(self): #开启服务 if self.status=='running': #执行服务前检测当前状态,根据状态不同做相应处理 print("the Server was running,dont't need to start&q…