Python file methods
- Föregående Sida Python Samlingar Metoder
- Nästa Sida Python Nyckelord
Python has a set of methods that can be used with file objects.
Method | Description |
---|---|
close() | Close the file. |
detach() | Return the separated original stream (raw stream) from the buffer. |
fileno() | Return the numeric representation of the stream from the perspective of the operating system. |
flush() | Flush the internal buffer. |
isatty() | Return whether the file stream is interactive. |
read() | Return the content of the file. |
readable() | Return whether the file stream can be read. |
readline() | Return a single line from the file. |
readlines() | Return the list of lines in the file. |
seek() | Ändra filposition. |
seekable() | Returnerar om filen tillåter oss att ändra filpositionen. |
tell() | Returnerar den aktuella filpositionen. |
truncate() | Justera filen till angiven storlek. |
writeable() | Returnerar om det är möjligt att skriva till filen. |
write() | Skriv in angiven sträng till filen. |
writelines() | Skriv in en stränglista till filen. |
Vänligen använd vår Python Filhantering Tutorial Lär dig mer om filobjekt.
- Föregående Sida Python Samlingar Metoder
- Nästa Sida Python Nyckelord