代码如下:
#encoding=utf-8
print '中国'
#随机输入输出
#一个大的二进制文件,读取某一条记录,不需要逐条读取
'''d:\123.txt的内容
1 a b c 中 国
2 a b c 中 国
'''
thefile = open(r'd:\123.txt','rb')
record_size = 2
record_num = 2
thefile.seek(record_num * record_size)
buffer = thefile.read(record_size)
print buffer
thefile.close()
打印结果如下:
中国
b