Changes

Jump to: navigation, search

OPS435 Python Lab 5

380 bytes added, 07:59, 5 September 2017
PART 2 - Writing To Files
== PART 2 - Writing To Files ==
:xUp to this point, you have learned how to access data from a file. In this section, you will learn how to write data to a file. Writing data to a file is useful for creating new content in a file or updating (modifying) existing data contained within a file.
:'''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 accidentally erasing the existing contents of a file when writing data to a file. When opening files for writing(i.e. using the ''''w'''' open function attribute), Python assumes existing content in the file is no longer wanted and it's immediately deleted; therefore, if you wish to keep existing data in doubta file, use the open file attribute ''''a'''' to append new data to the a file instead!.}}</blockquote>
::#To start, open the ipython3 shell:<source lang="python">
ipython3
13,420
edits

Navigation menu