English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Tutoriel de base Python

Contrôle de flux Python

Fonctions en Python

Types de données en Python

Opérations sur les fichiers Python

Objets et classes Python

Python date and time

Advanced knowledge of Python

Python reference manual

Python file operation methods (File)

Python has a set of methods that can be used for file objects.

MethodDescription
close()Close the file.
detach()Return the separated raw stream (raw stream) from the buffer.
fileno()Return the numerical representation of the stream from the perspective of the operating system.
flush()Refresh the internal buffer.
isatty()Return whether the file stream is interactive.
read()Return the file content.
readable()Return whether it is possible to read the file stream.
readline()Return a line in the file.
readlines()Return the line list in the file.
seek()Change the file position.
seekable()Return whether the file allows us to change the file position.
tell()Return the current file position.
truncate()Adjust the file to the specified size.
writeable()Return whether it is possible to write to the file.
write()Write the specified string to a file.
writelines()Write a string list to a file.

In our Python file tutorial Learn more about file operations on Python.