File Handling: ============== What is file? ============= ==> to store the data permanently we can use "files". ==> two types of files: 1) Text Files ==> .txt ==> character data 2) Binary Files ==> binary data audio files, video files, image files etc. File Handling: =============== Open the file read the file write the file close file etc. How to Open the file: ===================== open(): ======= Syntax: file-pointer = open(filename, mode) File Modes: w-mode ==> write mode r-mode ==> read mode a-mode ==> append mode w+-mode ==> write + read mode r+-mode ==> read + write mode a+-mode ==> read + write w-mode: ======= 1) w-mode can able to open the existing file by flushing (override) the whole data. 2) w-mode can able to create the new file if the specified file-name is not exist. r-mode: ======= 1) r-mode can able to open the existing file without overriding of the data. 2) r-mode cannot able to create the new file if the specified filename is not existed. a-mode: ======= 1) a-mode can able to open the existing file without overriding of the data. 2) a-mode can able to create the new file if the specified file name is not existed. ==> a == reading + writing w-mode Vs a-mode: ================= 1) w-mode can write the data into file by overriding. 2) a-mode can write the data after the reading the old content (at the end of the old content). w+-mode: ======== 1) w+-mode can open the existing file without overriding the data. 2) w+-mode while writing into an existing file, it can override the old content. 3) w+-mode can create the new file if the specified file is not existed. r+-mode: ========= 1) r+-mode also can able to open the existing file only. 2) r+-mode can overwrite the data. a+-mode: ======== x-mode: ====== same like w-mode can't be open the existing file.