搜索
您的当前位置:首页正文

python中怎么读取doxc文件?

来源:二三四教育网

python中可以使用python-docx库读取doxc文件,我们可以使用pip install python-docx命令安装python-docx库。

1、新建或打开文件。这个比较简单用docx的Document类,若指定路径则是打开文档;若没有指定路径则是新建文档

#coding:utf-8
import docx
 
#新建文档
doc_new = docx.Document()
 
#读取文档
doc = docx.Document(ur'C:\1.docx')

更多Python知识请关注

Top