我正在创建一个使用凯撒密码对消息进行编码和解码的程序。到目前为止,我正在构建基础工作,我正在尝试获取用户给我的字符列表并使用 ord 制作整数列表......到目前为止,我遇到的所有问题是将收到的整数重新放入一个列表。
import random
encode_decode = input("Do you want to encode, or decode? (e/d)")
shift_amount = input("Please enter the shift amount for your message")
if encode_decode == "e" or encode_decode == "E":
user_words_unrefined = input("Enter your message to encode!")
elif encode_decode == "d" or encode_decode == "D":
user_words_unrefined = input("Enter your message to decode!")
user_words_refined = list(user_words_unrefined)
Alphabet = [chr(i) for i in range(ord('a'), ord('z') + 1)]
Counter = 0
for i in range(len(user_words_refined)):
user_words_numbers = (ord(user_words_refined[Counter]))
user_numbers_list = [user_words_numbers]
print(user_numbers_list)
Counter += 1
输入(“你好,党的人!”)输出它将它们全部打印在单独的行上,并用方括号括起来......有什么想法吗?
[72]
[101]
[108]
[108]
[111]
[44]
[32]
[80]
[97]
[114]
[116]
[121]
[32]
[112]
[101]
[111]
[112]
[108]
[101]