+ 2

Can anyone help how to open microsoft word file in python 3 using open statement

13th Nov 2020, 5:26 PM
Dino Gupta
Dino Gupta - avatar
6 Antworten
+ 4
Microsoft Word documents are not plain text files, so you can't simply use `open` command for that like you would open a text file. A quick search on the net for this topic lead me to a conclusion that a module is needed to do the task. I will leave you with the related links resulted from the search https://stackabuse.com/reading-and-writing-ms-word-files-in-JUMP_LINK__&&__python__&&__JUMP_LINK-via-python-docx-module/ https://python-docx.readthedocs.io/en/latest/index.html
13th Nov 2020, 6:00 PM
Ipang
+ 2
Thanks everyone
13th Nov 2020, 6:02 PM
Dino Gupta
Dino Gupta - avatar
+ 1
file = open("/storage/emulated/0/Documents/Dino sololearn.docx", "r") cont = file.read() print(cont) file.close()
13th Nov 2020, 5:31 PM
Dino Gupta
Dino Gupta - avatar
+ 1
The above was the code which i have written
13th Nov 2020, 5:31 PM
Dino Gupta
Dino Gupta - avatar
0
Dino Gupta It wont work 😁 And also not work in Sololearn You have to use any IDE in computer like visual code studio ,sublime text etc ... If u have word file upload it to dropbox and use its link.. file = open("paste file link here", "r") cont = file.read() print(cont) file.close()
13th Nov 2020, 5:59 PM
Mr. Rahul
Mr. Rahul - avatar
0
R...K What is the difference between my and your code??
13th Nov 2020, 6:03 PM
Dino Gupta
Dino Gupta - avatar