梓潼网站建设,花生壳免费域名申请,wordpress+icon图标,免费ftp 网站公司归档文件比较麻烦#xff0c;于是用Python写了个程序自动归档#xff0c;运行无错误。但是运行完后问题就来了#xff0c;自己手动打开word文档时速度变得奇慢#xff0c;打开一个文档需要1~2min,请各位同仁帮我看看。下为源代码#归档.pyimport osimport refrom win32c…公司归档文件比较麻烦于是用Python写了个程序自动归档运行无错误。但是运行完后问题就来了自己手动打开word文档时速度变得奇慢打开一个文档需要1~2min,请各位同仁帮我看看。下为源代码#归档.pyimport osimport refrom win32com import client as wcdef file(paths,sname,version):for path1 in os.listdir(paths):mre.match(r.*\.docx?$,path1)if m:path0paths\path1print(path0)wordwc.Dispatch(Word.Application)wword.Documents.Open(path0)sstr(word.ActiveDocument.Sections[3].Headers[0])dstr(word.ActiveDocument.Sections[3].Footers[0])t1re.match(rTE.{14},d)T1t1.group(0)t2re.search(r(\w.*\w),s)T2t2.group(0)if T2.find(\r)0:T2T2.replace(\r,)t3re.search(r(共\d页),d)T3t3.group(0)w.Close()word.Quit()T[T1,T2,sname,version,T3]M.join(T)path3paths\M.docprint(path3)os.renames(path0,path3)print(done)pathsinput(Please enter a path:)snameinput(Please enter a name for short:)versioninput(Please enter version(default A):)if version:versionAfile(paths,sname,version)还有就是程序在DOS窗口运行时经常会卡住不能往下执行。使用IDLE编辑器则运行良好。跪谢你把 .docx 改成了 .doc与这个无关。我文件夹里的文档本来就都是.doc格式的并未改后缀名。并且我刚才把程序中的.docx改 成了.doc结果还是一样word的打开会很慢movi看看你的文档是不是原来打开就很慢~太多的格式图片外链……word对象移到for外边~wordwc.Dispatch(Word.Application)for path1 in os.listdir(paths):…………word.Quit()