下面的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()