我在Windows 7 64字節中使用Spyder 2.3.7和Python 2.7.10。Python file.tell()給出錯誤的值
我想讀取文本文件,並且想要在讀取一行後讀取文件中的位置;主要原因是稍後可以在完成一些搜索後返回到文件中。 不管,當我使用下面的代碼:
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 <[email protected]>
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
上面的代碼有什麼問題,如果我使用二進制讀取或沒有不同,沒什麼不同。
作品完美,感謝您的信息,抱歉,沒有足夠的代表來投票回答。 – RobertoST