输出不正确,蹲正确解答

key = int(input())
res = []
with open('in.txt', 'r') as f:
for line in f.readlines():
line = line.rstrip()
temp = ''
for i in line:
if i >= 'a' and i <= 'z':
i = chr(ord('a') + (ord(i) - ord('a') + key) % 26)
elif i >= 'A' and i <= 'Z':
i = chr(ord('A') + (ord(i) - ord('a') + key) % 26)
temp += i
res.append(temp)

with open('out.txt', 'w') as f:
for line in res:
f.write(line +'\n')

又是缩进问题

key = int(input())
res = []
with open('in.txt', 'r') as f:
    for line in f.readlines():
        line = line.rstrip()
        temp = ''
        for i in line:
            if i >= 'a' and i <= 'z':
                i = chr(ord('a') + (ord(i) - ord('a') + key) % 26)
            elif i >= 'A' and i <= 'Z':
                i = chr(ord('A') + (ord(i) - ord('A') + key) % 26)
            temp += i
        res.append(temp)

with open('out.txt', 'w') as f:
    for line in res:
        f.write(line +'\n')

你要干啥?