13,420
edits
Changes
→PART 2 - Writing To Files
::#To start, open the ipython3 shell:<source lang="python">
ipython3
</source>::#<br>When opening a file for writing, the ''''w'''' option can be give to is specified with the '''open()''' function. When the 'w' option is provided the specified, previous contents inside the file are deleted, this deleting . This deletion takes place the moment the open() function is executed, not during as opposed to the writeactual writing process. If the file that is being written to doesn't exitexist, it the file will be createdupon the file opening process.<br><br>::#Let's open a non-existent file (called file1.txt) for writing.Issue the following command:<source lang="python">
f = open('file1.txt', 'w')
</source>