from collections import deque
with open('somefile') as fin:
last3 = deque(fin, 3)
from collections import deque
with open('somefile') as fin, open('outputfile', 'w') as fout:
fout.writelines(deque(fin, 3))
在python中复制文本文件的最后三行?
from collections import deque
with open('somefile') as fin:
last3 = deque(fin, 3)
from collections import deque
with open('somefile') as fin, open('outputfile', 'w') as fout:
fout.writelines(deque(fin, 3))