Changes

Jump to: navigation, search

OPS435 Python Lab 5

141 bytes added, 08:37, 5 September 2017
PART 2 - Writing To Files
f.close()
</source>
::#Issue the following command to view the contents of the file to make sure the write data was saved. We can use The cat command should work, but if you experience any problems, place a % sign in front of the command. This represents the ipython bash '''alias ''' for the cat command (i.e. '''%cat to do this''').<source lang="python">cat file1.txt%cat file1.txtLine 1Line 2 is a little longerLine 3 is # should display the same results as wellthe cat command
</source>
::#Create another file but this time, run multiple write() methods together. 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.<source lang="python">
13,420
edits

Navigation menu