How to read a few characters from certain position in a text file in Python

1 Answer

0 votes
fh = open("d:\\data.txt")

print(fh.tell())
fh.seek(3)
print(fh.tell())

s = fh.read(2)

print(s)


'''
run:

0
3
ho

'''

 



answered Dec 21, 2017 by avibootz

Related questions

1 answer 267 views
1 answer 257 views
1 answer 291 views
1 answer 270 views
2 answers 387 views
3 answers 445 views
1 answer 303 views
...