reading and writing files introduction reading data from and writing data to file is very common within many programs python provides large amount of support for working with files of various types this introduces you to the core file io functionality in python obtaining references to files reading fromand writing totext files in python is relatively straightforward the built in open(function creates file object for you that you can use to read andor write data from andor to file the function requires as minimum the name of the file you want to work with optionally you can specify the access mode ( readwriteappend etc if you do not specify mode then the file is open in read-only mode you can also specify whether you want the interactions with the file to be buffered which can improve performance by grouping data reads together the syntax for the open(function is file_object open(file_nameaccess_modebufferingwhere file_name indicates the file to be accessed access_mode the access_mode determines the mode in which the file is to be openedi readwriteappendetc complete list of possible values is given below in the table this is an optional parameter and the default file access mode is read ( (cspringer nature switzerland ag huntadvanced guide to python programmingundergraduate topics in computer science