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 169 views
1 answer 203 views
1 answer 172 views
1 answer 181 views
2 answers 250 views
3 answers 287 views
1 answer 175 views
...