参考答案是错误的,没有考虑换行符
OpenFile = open("source.txt","r")
lines = OpenFile.readlines()
CreateFile = open("target.txt","w")
for i in lines:
Ri = i[::-1]
if lines.index(i) == -1:
break
Ri = Ri.strip()
Ri = Ri+"\n"
CreateFile.write(Ri)
OpenFile.close()
CreateFile.close()