自动化软件

from win32com import client as wc # 导入模块
from pathlib import Path
import os
import shutil

doc_path = r”E:tmp答疑整理”
temp_dir = “temp”
if os.path.exists(f”{doc_path}/{temp_dir}”):
shutil.rmtree(f”{doc_path}/{temp_dir}”)
os.mkdir(f”{doc_path}/{temp_dir}”)

word = wc.Dispatch(“Word.Application”) # 打开word应用程序https://win8.com/
try:
for filename in Path(doc_path).glob(“*.doc”):
file = str(filename)
dest_name = str(filename.parent/f”{temp_dir}”/str(filename.name))+“x”
print(file, dest_name)
doc = word.Documents.Open(file) # 打开word文件
doc.SaveAs(dest_name, 12) # 另存为后缀为”.docx”的文件,其中参数12指docx文件
finally:
word.Quit()

来源:普通网友

声明:本站部分文章及图片转载于互联网,内容版权归原作者所有,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2021年1月12日
下一篇 2021年1月12日

相关推荐