python3 seek

Solutions on MaxInterview for python3 seek by the best coders in the world

showing results for - "python3 seek"
Marta
05 Jan 2020
1>>> f = open('workfile', 'rb+')
2>>> f.write(b'0123456789abcdef')
316
4>>> f.seek(5)      # Go to the 6th byte in the file
55
6>>> f.read(1)
7b'5'
8>>> f.seek(-3, 2)  # Go to the 3rd byte before the end
913
10>>> f.read(1)
11b'd'
12