+-

我正在尝试使用docx库,但是我收到了这个错误:
AttributeError: 'module' object has no attribute 'Document'
这是我的代码:
import docx
document = docx.Document('file.docx')
怎么了?我已在其他计算机上使用过文档.我使用pip安装了docx库:
pip install docx
最佳答案
你的软件包docx与软件包python-docx混淆了.
pip install python-docx
>>> import docx
>>> docx.Document
<class 'docx.api.Document'>
但你说得对,这是一个问题.
点击查看更多相关文章
转载注明原文:python – Docx库无法识别Document方法 - 乐贴网