Changes

Jump to: navigation, search

OPS435 Python Lab 5

13 bytes removed, 09:40, 5 September 2017
PART 2 - Writing To Files
:'''Perform the Following Steps:'''
<blockquote style="margin-left:35px;">{{Admon/caution|style="padding-left:25px"|Risk of Losing File Contents|A common problem that new Python programmers may encounter is to accidentally erase existing contents of a file when writing new data to a file. When opening files for writing (using the ''''w'''' open function optionattribute), Python assumes existing content in the file is no longer wanted and it's immediately deleted; therefore, if you wish to write data to a file but keep existing content, it is recommended to use the open file option attribute ''''a'''' in order to append new data to a file.}}</blockquote>
::#To start, open the ipython3 shell:<source lang="python">
ipython3
f.close()
</source>
::#Issue View the following command to confirm that contents of the contents were written to file2.txt:to make sure the write data was saved.<source lang="python">
cat file2.txt
</source>
13,420
edits

Navigation menu