# How to know the current position within a file in Python?

PythonServer Side ProgrammingProgramming

You can get the current position of the file object using the tell method. For example, if there is a file called my_file with text Hello\nworld,

f = open('my_file.txt', 'r')
f.close()