I am able to edit & save txt without problem but when I save the docx file, data gets corrupted. Like the image here: image of error Any suggestions to save docx properly? Thanks.
def save(self,MainWindow):
if self.docURL == "" or self.docURL.split(".")[-1] == "txt":
text = self.textEdit_3.toPlainText()
file = open(self.docURL[:-4]+"_EDITED.txt","w+")
file.write(text)
file.close()
elif self.docURL == "" or self.docURL.split(".")[-1] == "docx":
text = self.textEdit_3.toPlainText()
file = open(self.docURL[:-4] + "_EDITED.docx", "w+")
file.write(text)
file.close()