我想使用python 2.7.6(32位)读取一个大文件(1.4 GB)。 但是,我尝试的解决方案并不起作用。例如,如果我运行以下代码:
os.system('dir') # gives me 20/03/2014 16:55 1 414 488 081 book.review
with open('book.review') as f:
tmp = 0
for line in f:
print line
for c in line:
tmp += 1
tmp
的值是6642.
最重要的是,最后一行是
Like Calhoun the support for states rights remains a complete fa
而相应的行是
Like Calhoun the support for states rights remains a complete fa^Zade. I found Russell Kirk's salesmanship of Conservativism generally repellent but recommend the book because it remains a fairly enlightening view of an ideology that continues to thrive to this day.
最重要的是,这是39001831行文件中的第93行。
我真的可以对这个问题采用新的眼光,我真的不明白会发生什么。
问题显然来自^Z
(在提问时未发现)。但是,我无法摆脱它(像line.replace('^Z', '')
这样的东西)还不够。