Docsity

Python File Methods: A Comprehensive Guide, Summaries of Programming Languages

Toggle sidebar
bg1
Python File Methods
MethodDescription
Close() Closes the file
Detach() Returns the separated raw stream from the buffer
Fileno() Returns a number that represents the stream, from the operating system’s perspective
Flush() Flushes the internal buffer
Isatty() Returns whether the file stream is interactive or not
Read() Returns the file content
Readable() Returns whether the file stream can be read or not
Readline() Returns one line from the file
Readlines() Returns a list of lines from the file
Seek() Change the file position
Seekable() Returns whether the file allows us to change the file position
Tell() Returns the current file position
Truncate() Resizes the file to a specified size
Writable() Returns whether the file can be written to or not
Write() Writes the specified string to the file
Writelines() Writes a list of strings to the file

Partial preview of the text

Download Python File Methods: A Comprehensive Guide and more Summaries Programming Languages in PDF only on Docsity!

Python File Methods MethodDescription Close() Closes the file Detach() Returns the separated raw stream from the buffer Fileno() Returns a number that represents the stream, from the operating system’s perspective Flush() Flushes the internal buffer Isatty() Returns whether the file stream is interactive or not Read() Returns the file content Readable() Returns whether the file stream can be read or not Readline() Returns one line from the file Readlines() Returns a list of lines from the file Seek() Change the file position Seekable() Returns whether the file allows us to change the file position Tell() Returns the current file position Truncate() Resizes the file to a specified size Writable() Returns whether the file can be written to or not Write() Writes the specified string to the file Writelines() Writes a list of strings to the file