io.FileIO

class io.FileIO

file(name: str[, mode: str]) -> file IO object

Open a file. The mode can be ‘r’ (default), ‘w’ or ‘a’ for reading, writing or appending. The file will be created if it doesn’t exist when opened for writing or appending; it will be truncated when opened for writing. Add a ‘+’ to the mode to allow simultaneous reading and writing.

Methods

__enter__
__exit__
__format__ default object formatter
__new__((S, ...)
__reduce__ helper for pickle
__reduce_ex__ helper for pickle
__sizeof__(() -> int) size of object in memory, in bytes
__subclasshook__ Abstract classes can override this to customize issubclass().
_checkClosed
_checkReadable
_checkSeekable
_checkWritable
close(() -> None.  Close the file.) A closed file cannot be used for further I/O operations.
fileno(...)
flush Flush write buffers, if applicable.
isatty(...)
read(...) Only makes one system call, so less data may be returned than requested In non-blocking mode, returns None if no data is available.
readable(...)
readall(...) In non-blocking mode, returns as much as is immediately available, or None if no data is available.
readinto(() -> Same as RawIOBase.readinto().)
readline Read and return a line from the stream.
readlines Return a list of lines from the stream.
seek((offset: int[, ...) and return the file position.
seekable(...)
tell(() -> int.  Current file position.) Can raise OSError for non seekable files.
truncate(...) return the truncated size.
writable(...)
write((b) -> int.  Write array of bytes b, ...) Only makes one system call, so not all of the data may be written.
writelines

Attributes

closed True if the file is closed
closefd True if the file descriptor will be closed by close().
mode String giving the file mode
next