Today’s Progress
- ex16: Reading and Writing Files. To write to a file, open it with mode “w” as the second parameter, if the file exists, opening it in write mode clears out the current data there. If the file does not exist, a new one is created.
target = open((filename, 'w')
target.truncate()
- ex17: More Files. This exercise takes 3 arguments, takes the contents of one file and writes it into another, second file.
Thoughts: Truncate() was not familiar to me. In the exercise the use of target.truncate() to clear out the current data in a text file before we added our own new data with target.write. There’s so many things you can do with files and methods.
Link to work: exercises 16-17