Python File Handling Till now, we were taking the input from the console and writing it back to the console to interact with the user. Sometimes, it is not enough to only display the data on the console. The data to be displayed may be very large, and only a limited amount of data can be displayed on the console, and since the memory is volatile, it is impossible to recover the programmatically generated data again and again. Opening a file Python provides the open() function which accepts two arguments, file name and access mode in which the file is accessed. The function returns a file object which can be used to perform various operations like reading, writing, etc. The syntax to use the open() function is given below. ⦁ file object = open(<file-name>, <access-mode>, <buffering>) The files can be accessed using various modes like read, write, or append. The following are the details about the access mode to open a file. SN Access mode Descrip...
Comments
Post a Comment