我有一个文件,看起来像这样alt text http://img40.imageshack.us/img40/4581/crapq.png 现在显示了 5 行。但是运行这个脚本
with open('hello.txt', 'r') as hello:
for line in hello:
print line,
给予
num 1
ctl00$header1$Login1$txtUserName=ыют;CBШ▌
就是这样。如何读取整个文件?时间差
请您参考如下方法:
entire_file = open('hello.txt', 'rb').read()
print 'number of \\n: %d, number of bytes %d' % (
entire_file.count('\n'), len(entire_file))
