ReferenceFile methods
file.seek()
Moves the read position, usually back to the start.
Signature
f.seek(offset)Parameters
| Name | Means |
|---|---|
offset | where to move to, in bytes from the beginning |
Returns
The new position.
Example
Python
with open("notes.txt", "w", encoding="utf-8") as f:
f.write("Ada")
with open("notes.txt", encoding="utf-8") as f:
print(f.read())
print(repr(f.read()))
f.seek(0)
print(f.read())Output
Ada '' Ada