我一直遇到相同的错误。错误不断出现,不用做什么。我正在尝试制作一个密码系统。代码运行,但错误不断出现。我一遍又一遍。
message = raw_input("text: ")
crypt = ' '
letters = 'abcdefghijklmnopqrstuvwxyz0123456789;:[]'
key = len(letters)/2
for char in message:
if char in letters:
ans = letters.find(char)
ans = ans + key
if ans >= len(letters):
ans = ans - len(letters)
elif ans < 0:
ans = ans + len(letters)
crypt = crypt + letters[ans]
else:
crypt = crypt + char
print("Encryption: ").format(crypt)
decrypt = crypt
word = "Not found"
for ans in range(len(letters)):
dec = ''
for Al in crypt:
if Al in letters:
dec = letters.find(Al)
dec = dec - key
if dec < 0:
dec = len(letters) + dec
dec = dec + letters [dec]
else:
dec = dec , Al
print ('Answers {} {}'.format(key, dec))
print("decryption: ")