接收错误ValueError:chr()arg不在范围内(256)

时间:2016-01-27 21:45:41

标签: python ascii

elif chosenA == 2:
print('''You have chosen to decrypt a message,''')
print("Please enter the name of the file you wish to decrypt")
a = raw_input()
with open(a + '.txt') as text:
    lar = text.read()
    print(lar)
MS = 0
print("oi drongo enter ya key")
b = raw_input()

for c in b:
    f = ord(c)
    MS = MS + f
geek = (MS / 8) - 32
#print(geek)

nlar = ''

for c  in lar:
    g = ord(c)
    if g > 126:
        g -= 94
    g -= geek
    f = unichr(g)
    print(f)

在“for c in lar:”期间我试图使用ord()将文件中的字符转换为ascii值,然后如果它们大于126(字母表),则从值中删除94从ascii值中取出geek(由8个字符键生成的偏移因子),这样它就会返回到最初加密的文本,如果你想要完整的代码只是说,如果它有帮助我会提供它。 / p>

0 个答案:

没有答案