返回顶部

收藏

Use seek() to move file pointer

更多
f = open('/tmp/workfile', 'r+')
f.write('0123456789abcdef')
f.seek(5)     # Go to the 6th byte in the file
print f.read(1)        

f.seek(-3, 2) # Go to the 3rd byte before the end
print f.read(1)

f.close()

标签:Python,File

收藏

0人收藏

支持

0

反对

0

»更多 您可能感兴趣的代码
  1. 2017-03-11 19:36:33Open a file and read char by char by 阿明娃儿
  2. 2016-01-01 13:50:06Looping through the file, line by line. by xwz
  3. 2016-03-06 20:01:32Handle File reading Exception by 西国の海妖
  4. 2016-12-24 10:24:24Reading a file: readlines and xreadlines by 张宋付
  5. 2016-11-27 10:13:11Reading the newly created file. by 山药
  6. 2016-01-02 10:12:28Copy file and move dir by Solon.Ring
  7. 2016-11-27 14:14:10File readline() by 张宋付
  8. 2013-06-04 13:43:27web.py中自定义jinja2模块 by 赵小全
  9. 2015-02-23 09:40:23ubuntu安装python3的python-pip by 甄码农
  10. 2016-09-19 19:25:12File Output by jack.chen
  11. 2016-10-19 10:47:50Handling I/O Errors by 大猪

发表评论