Skip to content

Latest commit

 

History

History
16 lines (12 loc) · 782 Bytes

how to open a text file in python.md

File metadata and controls

16 lines (12 loc) · 782 Bytes

The syntax to open a file object in Python is:

file_object  = open(�filename�, �mode�)  

"file_object" is the variable to add the file object.
"filename" is the... file name! :)
"mode" tells the interpreter which way the file will be used.

The modes are:

�r� � Read mode which is used when the file is only being read
�w� � Write mode which is used to edit and write new information to the file (any existing files with the same name will be erased when this mode is activated)
�a� � Appending mode, which is used to add new data to the end of the file; that is new information is automatically amended to the end
�r+� � Special read and write mode, which is used to handle both actions when working with a file