Python File Methods


Python has a set of methods available for the file object.

Method Description
Closes the file
detach() Returns the separated raw stream from the buffer
Returns a number that represents the stream, from the operating system's perspective
Flushes the internal buffer
Returns whether the file stream is interactive or not
Returns the file content
Returns whether the file stream can be read or not
Returns one line from the file
Returns a list of lines from the file
Change the file position
Returns whether the file allows us to change the file position
Returns the current file position
Resizes the file to a specified size
Returns whether the file can be written to or not
Writes the specified string to the file
Writes a list of strings to the file

Learn more about the file object in our .




Login
ADS CODE