python代码求解释


with open('text.txt',mode='r') as t:
    count = len(t.readlines())
x = open('text.txt',mode='r').read().splitlines()
new = ''
for i in range(count):
    new = x[i]
    new1 = new[::-1]
    with open('text2.txt',mode='a') as t2:
        t2.write(new1+'\n')
t2.close

这个代码将一个文本文件中的每行字符串进行反转,并将反转后的字符串写入另一个文本文件
其中 new1 = new[::-1] 这里是反转