Please enable JavaScript.
Coggle requires JavaScript to display documents.
Files,Modules and Packages (format operator (.format function (syntax:<…
Files,Modules and Packages
-
File operations
-
file open
syntax1: <file_name>=open("filepath",<mode>)
-
-
file modes
r Opens a file for reading only.
r+ Opens a file for both reading and writing.
w Opens a file for writing only. Overwrites the file if the file exists.
w+ Opens a file for both writing and reading.
a Opens a file for appending. File pointer is at the end of the file.
a+ Opens a file for both appending and reading.
Attributes
file.closed If file is closed returns true else false
file.mode Returns one of the mode
file.name Returns name of the file.
file.softspace Returns false if space explicitly required with print, true otherwise.
-
-
format operator
-
-
-
general syntax for format operator:<format expression> % (v1, v2, v3...vn)
-
-
.format function
-
-
syntax:<format expression> .format (v1, v2, v3...vn)
-
-
-
modules
python code consisting of functions,classes,variable
import statement
-
import module1[, module2[,... moduleN]
-
-
-
pickling
-
For Write : pickle.dump(<datatype variable>, <filename>)
For Read : pickle.load(<filename>)