博客园 :: :: 博问 :: 闪存 :: 新随笔 :: :: :: 管理 ::
 1 #encoding:utf-8
 2 import struct
 3 
 4 myfile = open("D:\\Backup\\我的文档\\spider.sav","rb+")
 5 
 6 myfile.seek(-4,2)#从末尾向前4个字节,只有这样才准确。
 7 myfile.write(struct.pack('I',1000))
 8 
 9 myfile.seek(-4,2)
10 value = struct.unpack('I',myfile.read(4))[0] #I即Integer,占4个字节 
11 
12 print (value)
13 myfile.close()
14 '''
15 源码保存为utf-8无BOM格式
16 '''

 

posted on 2015-05-12 11:01  #include<stdio.h>  阅读(567)  评论(0编辑  收藏  举报