红颜莎娜
infile = open("message.txt", "r") 打开文件outfile = open("newMsg.txt", "w")count = 0stringList = infile.readlines() 读取所有行for line in stringList: lineList = line.split() 按行分割 for word in lineList: count = count + 1 word = word[::-1] 反转 print(word, end = ' ') outfile.write(word + ' ') if count == 10: print('') outfile.write('\n') count = 0infile.close()outfile.close()