zoukankan      html  css  js  c++  java
  • File_attack记录

    GITHUB链接:github source

    回顾与记录:

    1、多线程。

    python多线程是后面在添加socket服务器的时候才用到的。使用的是threading.Thread类继承的办法实现。

    使用了生产者和消费者模式。 在这里是使用sys_status作为 产品。 当sys_status为false时,停止生产和消费。整个程序结束。

    2、多附件的添加:

    attach为['file_dir',"file_dir2']

    attach应该为已经过滤过的文件目录list

    每次添加的文件也不宜过多,过大。

    这里是emailclient,只做发送的事,所以过滤都是在传入attach参之前需要解决的问题。

     for f in attach:
        #open with 'rb' to read non-text file
           with open(f,'rb') as f_attach:
               part = MIMEBase('application', 'octet-stream')
               part.set_payload(f_attach.read())
               Encoders.encode_base64(part)
               part.add_header('Content-Disposition',
                                'attachment; filename=""%s"' %os.path.basename(f))
               msg.attach(part)
       try:
    
           mailServer = smtplib.SMTP("smtp.qq.com")
           mailServer.login(gmail_user, gmail_pwd)
           mailServer.sendmail(gmail_user, to, msg.as_string().encode('utf-8'))
           mailServer.close()
       except KeyboardInterrupt:
           sys.exit()
  • 相关阅读:
    第二次结对编程作业
    团队项目-需求分析报告
    Beta阶段第四次会议
    Beta阶段第三次会议
    Beta阶段第二次会议
    Beta阶段第一次会议
    Beta设计和计划
    项目展示
    事后分析
    α版本发布说明
  • 原文地址:https://www.cnblogs.com/-Doraemon/p/4818491.html
Copyright © 2011-2022 走看看