Python——创建更加牛逼的对象
class Host:def __init__(self, hostname, ip):
self.hostname = hostname
self.ip = ip
def patch_repair(self):
#管理者方法(补丁修复顺序)
self.download_patch() #下载
self.install_patch() #安装
self.reboot_system() #重启
def download_patch(self):
#补丁下载
print("{} Start downloading the patch".format(self.hostname))
def install_patch(self):
#补丁安装
print("{} Start install patch".format(self.hostname))
def reboot_system(self):
#重启系统
print("{} Start reboot system".format(self.hostname))
if __name__ == '__main__':
h = Host("pc001", "192.168.89.67")
h.patch_repair()
页:
[1]