while True: words = input('请输入要编码的内容:') ans = int(input('请输入偏移量:')) if (words == 'break') or(ans == 'break'): break code = [] for w in words: num = ord(w) code.append(num) num = num + ans print(code) f = open('1.txt', 'w') res = str(code) f.write(res) f.close() print('编码结果已写入文件!')