Usage of open function in Python

Python open() function (built-in function)

The Python open() function is used to open a file, create a file object, and enable related methods to call it for reading and writing
open(name[, mode[, buffering]])
 parameter description :
name : a string value containing the name of the file you want to access. 
mode : mode determined the mode of opening files : read only, write, append, etc. all available values can be found in the complete list below. this parameter is not mandatory, and the default file access mode is read-only( r)。
buffering : if buffering if the value is set to 0, there will be no storage. if buffering if the value is set to 1, the file will be stored when accessed. if the buffering the value of is set to an integer greater than 1, indicating that this is the buffer size of the storage area. if a negative value is taken, the buffer size of the storage area is set to the system default. 

Testing
#test 
f = open('/data/test')
f.read()

#test 
f = open('/data/test.txt')
f.read()

Note: The file names in the single quotation mark path must be exactly the same. txt (be careful)
Otherwise, it cannot be read
.

Related articles