Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python file io

r - It opens the file to read-only mode.
The file pointer exists at the beginning.
The file is by default open in this mode if no access mode is passed.


rb - It opens the file to read-only in binary format.
The file pointer exists at the beginning of the file.


r+ - It opens the file to read and write both.
The file pointer exists at the beginning of the file.


rb+ - It opens the file to read and write both in binary format.
The file pointer exists at the beginning of the file.


w - It opens the file to write only.
It overwrites the file if previously
exists or creates a new one if no file
exists with the same name. The file pointer
exists at the beginning of the file.


wb - It opens the file to write only in binary format.
It overwrites the file if it exists previously or 
creates a new one if no file exists. The file pointer
exists at the beginning of the file.


w+ - It opens the file to write and read both. 
It is different from r+ in the sense that it overwrites
the previous file if one exists 
whereas r+ doesn't overwrite the previously written file.
It creates a new file if no file exists. The file pointer
exists at the beginning of the file.


wb+ - It opens the file to write and read both in binary format.
The file pointer exists at the beginning of the file.


a - It opens the file in the append mode. 
The file pointer exists at the end of the previously
written file if exists any. It creates a new file if
no file exists with the same name.


ab - It opens the file in the append mode in binary format.
The pointer exists at the end of the previously written file.
It creates a new file in binary format if no file exists with
the same name.


a+ - It opens a file to append and read both.
The file pointer remains at the end of the file if a file exists.
It creates a new file if no file exists with the same name.


ab+ - It opens a file to append and read both in binary format.
The file pointer remains at the end of the file.
Comment

PREVIOUS NEXT
Code Example
Python :: syntax error in python 
Python :: mute command discord.py 
Python :: matplotlib show image black and white 
Python :: dataframe change column types 
Python :: login view django 
Python :: multiprocessing in python 
Python :: python endless loop 
Python :: how to remove a specific element from an array in python 
Python :: the range() function 
Python :: how to make one list from nested list 
Python :: pyinstaller windows 
Python :: add element to list python 
Python :: datetime am pm python 
Python :: selenium 
Python :: float and int difference 
Python :: python docstring use 
Python :: sklearn.metrics accuracy_score 
Python :: delete function python 
Python :: python inherit from objects 
Python :: python how to find the highest even in a list 
Python :: python own function and map function 
Python :: group by data 
Python :: python __new__ 
Python :: set default dictionary in python 
Python :: python string to list without split 
Python :: activate venv in python 
Python :: add to list python 
Python :: pandas explode 
Python :: tkinter triangle 
Python :: how to add two strings in python 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =