python_异步任务

一、异步任务

实例:

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

 

posted @ 2019-11-30 21:48  xmb  阅读(853)  评论(0编辑  收藏  举报