<代码>导入操作系统,shutil,多克斯,再保险公司的时间 从win32com进口端wc #从所有级联目录读取文件到指定目录内 def count_files (file_dir): 数=0 p、d、f os.walk (file_dir): 对于c f: 如果c.split(“。”)[1]==耙缴? 数+=1 src_dir=os.path。加入(p c) 打印(src_dir) dst_dir=file_dir +“返回” 如果不是os.path.exists (dst_dir): os.makedirs (dst_dir) shutil。复制(src_dir dst_dir) 返回数 #提取每个多克斯简历文档里面的邮箱地址,我们这里使用python-docx模块来解决pip安装python-docx def count_mail (file_dir dst_file): mail_list=[] 为父、dirctiory文件os.walk (file_dir): f的文件: 医生=docx.Document (os.path.join(父母,f)) 模式=re.compile (r”([a - za - z0 - 9. - _ % + -) + @ \ [a-zA-Z0-9 \ t s -) + (\ [a-zA-Z0-9 \ t \ s] {2,4}))”, re.VERBOSE) 在doc.paragraphs:帕拉 为团体pattern.findall (para.text): mail_list.append ([0]。替换(" "," ")+“,”) 张开(dst_file ' w ') f: f.writelines (mail_list) 打印(“=====================邮件信息写入成功===================") #由于python-docx模块只能处理多克斯后缀,我们需要处理医生后缀的文件,必须通过win32com模块来把医生后缀转换成多克斯 def docxTodoc (old_doc new_doc): 词=wc.Dispatch (“Word.Application”) 父目录,文件os.walk (old_doc): f的文件: 医生=word.Documents.Open (os.path.join(父母,f)) #目标路径下的文件 new_filepath=os.path.join (new_doc f.split (“。”) [0] +“。docx”) 打印(new_filepath) 医生。SaveAs (new_filepath 12假”、“,没错,“”,假的,假的,假的,假的)#转化后路径下的文件 doc.Close () print (time.time ()) word.Quit () if __name__==癬_main__”: 打印(count_files (r " C: \用户桌面\ \ icestick \ 51 job_导出简历_20180917”)) count_mail (r“C: \用户桌面\ \ icestick \ new_doc”, r " C: \ \ icestick用户桌面\ \测试。txt”) old_doc=r“C: \用户桌面\ \ icestick \ 51 job_导出简历_20180917”#需要把医生目录转成多克斯格式的原目录 new_doc=r“C: \用户桌面\ \ icestick \ new_doc”#需要把医生目录转成多克斯格式的目标目录 mail_extract=r " C: \用户桌面\ icestick \ \测试。三种“#邮箱提取好的文件 如果不是os.path.exists (new_doc): os.mkdir (new_doc) 打印(“=====================目录创建成功======================") docxTodoc (old_doc new_doc) 打印(“=====================多克斯格式转换成功===================") count_mail (new_doc mail_extract) 其他: docxTodoc (old_doc new_doc) 打印(“=====================多克斯格式转换成功===================") count_mail (new_doc mail_extract) 代码>