需要使用python-docx模块
pip install python-docx
然后函数主体
import os import docx2pdf def word_to_pdf(file_path): pdf_file = file_path.replace(".docx", ".pdf") docx2pdf.convert(file_path, pdf_file) file_path = "example.docx" word_to_pdf(file_path)
标签:docx,word,python,file,path,pdf From: https://www.cnblogs.com/dashenblog/p/17084562.html