用python阅读文档
我试图用python读取文档,但并没有得到任何错误,但它也并没有显示文档中所写的内容用python阅读文档,python,Python,我试图用python读取文档,但并没有得到任何错误,但它也并没有显示文档中所写的内容 from docx import Document import os file = open('C:\\Users\\hamza\\Desktop\\Python\\qwe.docx','r', encoding='utf8' ) document =(file.read()) file.close() 尝试pip安装docx2txt from docx2txt import process imp
from docx import Document
import os
file = open('C:\\Users\\hamza\\Desktop\\Python\\qwe.docx','r', encoding='utf8' )
document =(file.read())
file.close()
尝试
pip安装docx2txt
from docx2txt import process
import os
path = r'C:\Users\hamza\Desktop\Python\qwe.docx'
text = process(path)
with open(os.path.basename(path) + '.txt', 'w') as f:
f.write(text)
参考此-这是否回答了您的问题?