[Python] python读取文件内容并获得读取位置 →→→→→进入此内容的聊天室

来自 , 2021-02-09, 写在 Python, 查看 189 次.
URL http://www.code666.cn/view/ff82db75
  1. #!/usr/bin/python
  2.  
  3. # Open a file
  4. fo = open("/tmp/foo.txt", "r+")
  5. str = fo.read(10);
  6. print "Read String is : ", str
  7.  
  8. # Check current position
  9. position = fo.tell();
  10. print "Current file position : ", position
  11.  
  12. # Reposition pointer at the beginning once again
  13. position = fo.seek(0, 0);
  14. str = fo.read(10);
  15. print "Again read String is : ", str
  16. # Close opend file
  17. fo.close()
  18. #//python/8339

回复 "python读取文件内容并获得读取位置"

这儿你可以回复上面这条便签

captcha