def encrypt_message(text, x):
text = list(text)
for y in text:
ord(text)
返回ord()期望长度为1的字符串,但找到列表
答案 0 :(得分:1)
问题是您已将text
传递给ord
函数,您需要传递y
。
但是因为字符串是可迭代的对象,所以你可以循环遍历字符串:
def encrypt_message(text, x):
return [ord(i) for i in text]