使用python按相反顺序读取文件如何使用python按相反顺序读取文件?我想把文件从最后一行读到第一行。
3 回答

慕盖茨4494581
TA贡献1850条经验 获得超11个赞
for line in reversed(open("filename").readlines()): print line.rstrip()
for line in reversed(list(open("filename"))): print(line.rstrip())
添加回答
举报
0/150
提交
取消