f = open("./test.txt",'r')
content = f.readlines()
f1=open("./test1.txt","w")
for line in content:
line=content[::-1]
f1.write(line)
f1.close()
f.close()
f = open("./test.txt",'r'),这里可以换成具体的文件路径,比如,
f = open('/Users/lihui/Desktop/hoho.txt', 'r')