Python File Methods

open(file, mode)Opens a file in the specified mode (e.g., ‘r’ for reading).
read(size)Reads and returns a specified number of bytes from the file.
readline()Reads a single line from the file.
readlines()Reads all lines from the file and returns them as a list.
write(string)Writes the given string to the file.
writelines(lines)Writes a list of lines to the file.
close()Closes the file, releasing its resources.
seek(offset, whence)Moves the file pointer to the specified position.
tell()Returns the current file pointer position.
flush()Flushes the file’s write buffer.