大文件建议用readlines ,从文件读取每一行,
with open('/tmp/log','r') as file:
for line in file.readlines():
print line.strip()
小文件用read()
with open('/tmp/log','r') as file:
print file.read()
大文件建议用readlines ,从文件读取每一行,
with open('/tmp/log','r') as file:
for line in file.readlines():
print line.strip()
小文件用read()
with open('/tmp/log','r') as file:
print file.read()