【发布时间】:2015-01-23 10:34:32
【问题描述】:
我的代码:
def Encryption(text):
for I in text:
string = ""
ASCII = ord(text)
Result = ASCII + Offset
if Result > 126:
Result -= 94
else:
Result = Result
ResultASCII = chr(Result)
string += ResultASCII
对于我的第一个 GCSE 课程,我们必须制作一个加密程序。我们必须做的最后一部分是实际加密您的消息的部分。我已经使用了这段代码,但是它出现了以下错误:
TypeError: ord() expected a character, but string of length # found
如何让它检测一个字符串而不是一个字符?
【问题讨论】:
标签: python python-3.x encryption ascii typeerror