Metoda find() v souboru Pythonu
Příklad
Změňte aktuální pozici souboru na 4 a vraťte zbytek řádku:
f = open("demofile.txt", "r")
f.seek(4)
print(f.readline())
Definice a použití
Metoda seek()
nastavuje aktuální pozici souboru v datovém proudu.
Metoda seek()
také vrátí novou pozici.
Syntax
file.seek(offset)
Hodnoty parametrů
Parameter | Description |
---|---|
offset | Required. A number representing the position to set the current file stream position. |
Další příklady
Příklad
Vraťte novou pozici:
f = open("demofile.txt", "r")
print(f.seek(4))