#打开一个txt文档用来写入数据 withopen('result2.txt','w')asfw: #遍历word段落内容列表 forcontextindocument.paragraphs: #以换行符转换成列表 text='\n') #按行写入,同时换行 fw.write(f"{text[0]}\n") #打印看看效果 print(text[0]) f.close() 用python将内容写入文件,写入数据出现重复多次 能...
打开 word文件 f = open('随便写写行.docx', 'rb')读取 word文件内容 document = Document(f)打印 word 文档段落内容2进制列表 print(document.paragraphs)打开一个txt文档用来写入数据 with open('result2.txt', 'w') as fw:遍历 word 段落内容列表 for context in document.paragraphs:以换行...