-2
我正在写一个加密程序在python中,我需要改变输入字符串ex:HELLO和输出:LIPPS。当我输入更多的单词时,我遇到问题。加密程序错误
def encr_ypt(s, n):
word=ord(s)
for i in range(len(s)):
if word >= 90 and word <= 97:
hsl = chr(63+n)
if word >= 122:
hsl = chr(95+n)
else:
hsl = chr(word+n)
return hsl
st=raw_input('input string : ')
print encr_ypt(st, 4)
这里是错误消息
input string : HELLO
Traceback (most recent call last):
File "encrypt.py", line 13, in <module>
print encr_ypt(st, 4)
File "encrypt.py", line 2, in encr_ypt
word=ord(s)
TypeError: ord() expected a character, but string of length 5 found
什么最好的方法我写“U'V'W'Z”和输出是性格?/^%,我希望输出回到'A' –