烦!!! 发表于 2020-8-24 09:13:43

一运行就报错

from docx import Document

file = Document('ABC.docx')

file.add_paragraph('我是正文 奈克瑟斯')

file.save('练习4.docx')

报错:Traceback (most recent call last):
File "C:\Users\Administrator\Word自动化\导入.py", line 7, in <module>
    file.save('练习4.docx')
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\docx\document.py", line 135, in save
    self._part.save(path_or_stream)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\docx\parts\document.py", line 111, in save
    self.package.save(path_or_stream)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\docx\opc\package.py", line 172, in save
    PackageWriter.write(pkg_file, self.rels, self.parts)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\docx\opc\pkgwriter.py", line 32, in write
    phys_writer = PhysPkgWriter(pkg_file)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\docx\opc\phys_pkg.py", line 141, in __init__
    self._zipf = ZipFile(pkg_file, 'w', compression=ZIP_DEFLATED)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\zipfile.py", line 1204, in __init__
    self.fp = io.open(file, filemode)
PermissionError: Permission denied: '练习4.docx'

1q23w31 发表于 2020-8-24 09:18:12

管理员运行试试

烦!!! 发表于 2020-8-24 09:22:33

1q23w31 发表于 2020-8-24 09:18
管理员运行试试

谢谢啦
页: [1]
查看完整版本: 一运行就报错