작업 디렉토리에서 파일에 액세스하려고 할 때 오류가 발생합니다. 이 파일은 @dsphoebe의 질문과 중복되지 않습니다. 왜냐하면 내가 열려고하는 파일이 .docx 파일이고 어떤 이유로 든 열 수 없기 때문입니다. 이제python-docx에있는 창에 패키지를 찾을 수 없습니다?
rootdir = 'C:\\Users\\me\\Documents\\Python\\mydocs\\'
for subdir, dirs, files in os.walk(rootdir):
for file in files:
print(file) #prints all word docs in my folder, just like I want
나는 DOCX 객체를 생성하는 문이 인쇄 문을 대체 지금
rootdir = 'C:\\Users\\me\\Documents\\Python\\mydocs\\'
for subdir, dirs, files in os.walk(rootdir):
for file in files:
doc = docx.Document(os.path.join(rootdir, file))
...
#continuing with what I wanted to do w/ the documents...
Error: "Package not found at '%s'" % pkg_file
docx.opc.exceptions.PackageNotFoundError: Package not found at 'my doc.docx'
, 즉 mydocs 다음 폴더에, 내 doc.docx 적절한 제목이며 확실히이다 .docx 파일. 이 특정 파일의 제목은 2 단어과 하나의 공백 (즉, 내 doc.docx)으로 구성됩니다. 그러나 유형 '문서'객체로의 변환은 ONE이라는 단어와 동일한 폴더에있는 다른 단어 doc에 대해 작동합니다.
rootdir = 'C:\\Users\\me\\Documents\\Python\\mydocs\\'
doc = docx.Document(os.path.join(rootdir, "Access.docx"))
Exited with code = 0
을하지만이되지 않습니다 :
이 작동
rootdir = 'C:\\Users\\me\\Documents\\Python\\mydocs\\'
doc = docx.Document(os.path.join(rootdir, "Able2Extract Professional.docx"))
Exited with code=1
그래서
two words.docx
작동하지 않을하지만
oneword.docx
는 것. 매우 혼란 스럽습니다. 누구나이 문제를 진단하는 방법을 알고 있습니까?
합니까 파일 "내 doc.docx '당신이 공간은 하이픈을 삽입하는 경우가 .DOCX 파일에 문제가 배제 것 때문 유용한 테스트의 오픈? OS 파일 열기 문제로 좁혀 야합니다. – scanny
아니요, my-doc.docx가 열리지 않습니다 :(즉, OS 파일 열기 문제가되는 것입니까? – Vince
** 내 목록에있는 문서 중 일부는 2007 년 이전이었습니다. 파이썬 - docx 처리 할 수 없습니다. 그건 내 문제는 여기에 ** 그 사람은 방금 너무 그들의 제목에 2 단어를 가지고 일어난> :/ – Vince