-6
目前正在創建一個Cesears密碼,特別是解密。不支持的操作數類型爲 - :'str'和'str' - 獲取此錯誤,我不知道爲什麼
for char in decryptString:
x = ord(char)
x = x - decryptVal #this is my negative shift
if x < 32:
x = x + 32
elif x > 126:
x = x - 95
result = result - chr(x)
print('')
print('Decrypted string: ')
print(result)
而且我經常收到:
TypeError: unsupported operand type(s) for -: 'str' and 'str'
我解密的消息,而不是
不知道爲什麼,希望得到一些見解:)
是什麼''decryptVal?你也從結果中減去'chr'(字符串),你不能從任何東西中減去字符 – jamylak 2013-05-01 13:06:37
結果是否需要先初始化? – 2013-05-01 13:07:07
哪一行發生錯誤? 'result = result - chr(x)'? – thegrinner 2013-05-01 13:07:35