Participer au site avec un Tip
Rechercher
 

Améliorations / Corrections

Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.

Emplacement :

Description des améliorations :

Module « io » Python 3.11.3

Classe « FileIO »

Informations générales

Héritage

builtins.object
    _IOBase
        _RawIOBase
            FileIO

Définition

class FileIO(_RawIOBase):

help(FileIO)

Open a file.

The mode can be 'r' (default), 'w', 'x' or 'a' for reading,
writing, exclusive creation 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.  A FileExistsError will be raised if it already
exists when opened for creating. Opening a file for creating implies
writing so this mode behaves in a similar way to 'w'.Add a '+' to the mode
to allow simultaneous reading and writing. A custom opener can be used by
passing a callable as *opener*. The underlying file descriptor for the file
object is then obtained by calling opener with (*name*, *flags*).
*opener* must return an open file descriptor (passing os.open as *opener*
results in functionality similar to passing None).

Constructeur(s)

Signature du constructeur Description
__new__(*args, **kwargs) Create and return a new object. See help(type) for accurate signature. [extrait de __new__.__doc__]
__init__(self, /, *args, **kwargs) Initialize self. See help(type(self)) for accurate signature. [extrait de __init__.__doc__]

Liste des attributs statiques

Nom de l'attribut Valeur
closed
closefd
mode

Liste des opérateurs

Opérateurs hérités de la classe object

__eq__, __ge__, __gt__, __le__, __lt__, __ne__

Liste des méthodes

Toutes les méthodes Méthodes d'instance Méthodes statiques Méthodes dépréciées
Signature de la méthodeDescription
__getattribute__(self, name) Return getattr(self, name). [extrait de __getattribute__.__doc__]
__repr__(self) Return repr(self). [extrait de __repr__.__doc__]
close(self) Close the file. [extrait de close.__doc__]
fileno(self) Return the underlying file descriptor (an integer). [extrait de fileno.__doc__]
isatty(self) True if the file is connected to a TTY device. [extrait de isatty.__doc__]
read(self, size=-1) Read at most size bytes, returned as bytes. [extrait de read.__doc__]
readable(self) True if file was opened in a read mode. [extrait de readable.__doc__]
readall(self) Read all data from the file, returned as bytes. [extrait de readall.__doc__]
readinto(self, buffer) Same as RawIOBase.readinto(). [extrait de readinto.__doc__]
seek(self, pos, whence=0) Move to new file position and return the file position. [extrait de seek.__doc__]
seekable(self) True if file supports random-access. [extrait de seekable.__doc__]
tell(self) Current file position. [extrait de tell.__doc__]
truncate(self, size=None) Truncate the file to at most size bytes and return the truncated size. [extrait de truncate.__doc__]
writable(self) True if file was opened in a write mode. [extrait de writable.__doc__]
write(self, b) Write buffer b to file, return number of bytes written. [extrait de write.__doc__]

Méthodes héritées de la classe _RawIOBase

__init_subclass__, __subclasshook__

Méthodes héritées de la classe _IOBase

__del__, __enter__, __exit__, __iter__, __next__, flush, readline, readlines, writelines

Méthodes héritées de la classe object

__delattr__, __dir__, __format__, __getstate__, __hash__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__