https://m7madmomani2.github.io/reading-notes2
At its core, a file is a contiguous set of bytes used to store data. This data is organized in a specific format and can be anything as simple as a text file or as complicated as a program executable. In the end, these byte files are then translated into binary 1 and 0 for easier processing by the computer.
Header: metadata about the contents of the file (file name, size, type, and so on)
Data: contents of the file as written by the creator or editor
End of file (EOF): special character that indicates the end of the file
These are the methods used in reading files
.read(size=-1)
: reads from the file based on the number of size bytes, if the value less than 0 or not entered it will read the whole file.readline(size=-1)
: same as the above but for the lines.readlines()
: reads the rest of the lines and return them as a list
These are the methods used in writing files
.write(string)
: This writes the string to the file..writelines(seq)
: This writes the sequence to the file. No line endings are appended to each sequence item. It’s up to you