Changes

Jump to: navigation, search

OPS435 Python Lab 5

82 bytes added, 07:40, 5 September 2017
PART 2 - Writing To Files
cat file1.txt
%cat file1.txt # should display the same results as the cat command
</source>::#Create another <br>You will now create a new file called file2.txt, but this time, run multiple write() methods togetherin a series of operations. The ability to write() multiple lines like this allows for writes to take place inside '''loops ''' and more complex programs to continuously write to a file.<br><br>::#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 too\n')
13,420
edits

Navigation menu