这是我的代码:
def encode(pattern, filename):
pattern = ['a','e','s','3']
message = open(filename, 'r+')
for letter in message:
if letter == pattern[0]:
letter == pattern[1]
elif letter == pattern[1]:
letter == pattern[0]
elif letter == pattern[2]:
letter == pattern[3]
else:
continue
message.close()
代码中可能存在一些缺陷,因为我只是 python 的业余爱好者,但是当我运行该函数时,文件保持不变。我究竟做错了什么?