Lấy vị trí hiện tại của file object dùng phương thức tell. Ví dụ file my_file.txt nội dung Hello\nworld:
f = open('my_file.txt', 'r')
f.readline()
print(f.tell())
f.close()
Kết quả: 6 (con trỏ ở đầu từ 'world').
Lấy vị trí hiện tại của file object dùng phương thức tell. Ví dụ file my_file.txt nội dung Hello\nworld:
f = open('my_file.txt', 'r')
f.readline()
print(f.tell())
f.close()
Kết quả: 6 (con trỏ ở đầu từ 'world').