Changes

Jump to: navigation, search

OPS435 Python Lab 5

8 bytes added, 08:47, 5 September 2017
PART 2 - Writing To Files
::#Issue the following commands:<source lang="python">
f = open('file2.txt', 'w')
f.write('Line 1\nLine 2 is a little longer\nLine 3 is tooas well\n')
f.write('This is the 4th line\n')
f.write('Last line in file\n')
Line 1
Line 2 is a little longer
Line 3 is too as well
</source>
::#In the event that the data in the file is important and should not be overwritten, we can append data to the end of the file instead. Use the option 'a' instead of 'w' to perform appending.<source lang="python">
13,420
edits

Navigation menu