下面的代码是关于python读取文件内容并获得读取位置的代码。
#!/usr/bin/python
# Open a file
fo = open("/tmp/foo.txt", "r+")
str = fo.read(10);
print "Read String is : ", str
# Check current position
position = fo.tell();
print "Current file position : ", position
# Reposition pointer at the beginning once again
position = fo.seek(0, 0);
str = fo.read(10);
print "Again read String is : ", str
# Close opend file
fo.close()