我在Windows7 64字节中使用Spyder2.3.7和Python2.7.10。你知道吗
我想读一个文件的文本,并且想读一行后在文件中的位置;主要原因是以后能够在文件中移回一些搜索完成后。 不管怎样,当我使用以下代码时:
FileOrig = "testtext{Number}";
for index_file in range(1, 2):
fileName = FileOrig.format(Number = str(index_file))
ff = open(fileName, "rb")
numline = 1;
for line in ff:
numline = numline + 1;
position = ff.tell();
print(position);
ff.close()
其中testtext1文件的内容是(这只是一个示例):
Overall accuracy
Overall accuracy
2.2603e+03
2.3179e+03
2.5265e+03
4.8463e+03
1.7547e+03
3.0143e+03
3.1387e+03
Overall accuracy
Overall accuracy
2.2414e+03
3.9409e+03
1.8902e+03
4.1157e+03
Overall accuracy
Overall accuracy
2.2275e+03
1.3579e+03
2.3712e+03
6.4970e+03
5.8891e+03
SPLITBIB.STY -- N. MARKEY <markey@lsv.ens-cachan.fr>
v1.17 -- 2005/12/22
This package allows you to split a bibliography into several categories
and subcategories. It does not depend on BibTeX, and any bibliography
may be split and reordered.
splitbib – Split and reorder your bibliography
This package enables you to split a bibliography into several categories and subcategories. It does not depend on BibTeX: any bibliography may be split and reordered.
这就产生了非常奇怪的结果:
916
916
916
916
916
916
916
916
916
916
916
916
916
916
916
916
916
916
916
916
916
916
916
916
916
916
916
916
916
916
916
916
916
916
916
916
916
916
916
916
916
916
916
上面的代码有什么问题,如果我使用二进制读取与否没有什么不同。你知道吗
在文件上混合迭代和使用文件方法将不起作用,因为迭代涉及使用预读缓冲区。用^{} 代替
file.tell
:根据^{} documentation :
相关问题 更多 >
编程相关推荐