函数定义def test()

def test(x):
    y=2*x+1
    return y
print(test(3))
简单计算
def
test(x): y=2*x+1 return y t=input('>>>') y=test(int(t)) print(y)
while True
    if cpu>90%
        连接服务器
        发邮件
        关闭连接
    if 内存>90%
        连接服务器
        发邮件
        关闭连接
    if 硬盘>90%
        连接服务器
        发邮件
        关闭连接  

函数的使用简化了代码的利用
...
def 邮件提醒:(内容) 连接服务器 发邮件 关闭连接 if cpu>90% 邮件提醒(cpu报警) if 内存>90% 邮件提醒(内存报警) if 硬盘>90% 邮件提醒(硬盘报警)

猜你喜欢

转载自www.cnblogs.com/wfl9310/p/8922415.html