when opening a file, the “wt” parameter indicated that we:
want to append to the end of the text file.
want to write data to a text file.
that we are opening a binrary file.
that we are reading from a text file.
1
Expert's answer
2018-08-22T12:55:08-0400
Answer: want to write data to a text file.
Example:
with open('example.txt', 'wt') as f: f.write("Hello")
Python will look in the same folder that you have saved this Python document for a file called example.txt. If it can’t find a file with this exact name then it creates it. The ‘wt’ stands for ‘write to’ and means you want to open the file in ‘write mode’ to edit its contents. This line f.write("Hello”) writes “Hello” to the file.
Comments
Leave a comment