一、异步任务
实例:
1 import yagmail,threading 2 def send_mail(): 3 smtp = yagmail.SMTP(host='smtp.163.com',user='[email protected]', 4 password='fsdfsf') 5 smtp.send(to = '[email protected]',cc=['[email protected]','[email protected]'], 6 subject='标题',contents='正文',attachments=r'写日志.py') 7 8 def async_send_mail(): #启动一个线程专门发邮件 9 t = threading.Thread(target=send_mail) 10 t.start()