2024-08-29 16:37:09 +08:00
|
|
|
from docx import Document
|
|
|
|
|
|
|
|
def read_docx(file_path):
|
|
|
|
# 尝试打开文档
|
|
|
|
try:
|
|
|
|
doc = Document(file_path)
|
|
|
|
except Exception as e:
|
|
|
|
print(f"Error opening file: {e}")
|
|
|
|
return
|
|
|
|
|
|
|
|
# 读取文档中的所有段落并打印它们
|
|
|
|
for para in doc.paragraphs:
|
|
|
|
print(para.text)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2024-09-13 15:03:55 +08:00
|
|
|
file_path="C:\\Users\\Administrator\\Desktop\\货物标\\zbfilesdocx\\招标文件正文(1)(1).docx"
|
2024-08-29 16:37:09 +08:00
|
|
|
read_docx(file_path)
|