Is there a way to "un-readline" a line of text from a file opened with open()
?
#!/bin/env python
fp = open("temp.txt", "r")
# Read a line
linein = fp.readline()
print(linein)
# What I am looking for comes here
linein = fp.unreadline()
# Read the same line
linein = fp.readline()
print(linein)
The input file temp.txt
:
FIRST_LINE
SECOND_LINE
Expected output:
FIRST_LINE
FIRST_LINE