+ 1

What file formats can be used in open() func and file.read file.write methods?

I am practicing with open(file) function and methods on Python. What file formats I can use if I don't want a txt file ? with open('file_name.txt', 'w') as f: f.write('Hello world!') For examle , I want to write an additional information to a doc file . Or initially to create it? I tried it once (docx format) but MS Word didn't open it. Or maybe there are methods to convert file?

1st Jul 2019, 4:37 AM
senselessmessinspace
senselessmessinspace - avatar
1 Antwort
+ 3
To open, edit or create ms office docx files, check out the python-docx library. https://python-docx.readthedocs.io/en/latest/
1st Jul 2019, 7:41 AM
Tibor Santa
Tibor Santa - avatar