Welcome to demofile.txt
This file is for testing purposes.
Good Luck!
Above Content Is In My Text File
How to read last 10 bytes from that text file? The expected output is:
Good Luck!
Welcome to demofile.txt
This file is for testing purposes.
Good Luck!
Above Content Is In My Text File
How to read last 10 bytes from that text file? The expected output is:
Good Luck!
in_file.seek(-10, 2) # where 2 denotes the reference point being the end of the file
So then:
in_file = open("demofile.txt", "rb") # opening for [r]eading as [b]inary
in_file.seek(-10, 2)
s = in_file.read(10)
print(s)
OUTPUT:
b'Good Luck!'