error: can't copy 'docx\templates\default-docx-template': doesn't exist or not a regular file --------------- Failed building wheel for python-docx; python-docx的安装使用;python操作word

本人第一安装python-docx很不幸就出现了,如下的错误:(如果你也遇到同样的错误,不要慌可以参考下面解决方案,由于第一次处理这种错误,如有不对欢迎大家多多批评指正

问题所在是因为我们的setuptools版本太低了

解决办法:

1.首先进行升级

pip install -U setuptools

2.切换到扩展库的安装目录执行以下命令       pip install python-docx

3.验证

# ecoding=utf-8
from docx import Document

document = Document('D:\\11.docx')  #打开文件demo.docx
for paragraph in document.paragraphs:
    print(paragraph.text)  #打印各段落内容文本

document.add_paragraph(
    'Add new paragraph', style='ListNumber'
)    #添加新段落

document.save('demo.docx') #保存文档

 

posted @ 2019-04-09 19:18  小张在搬砖  阅读(888)  评论(0编辑  收藏  举报