这就是我不确定的地方:
import sys
message = input("enter message here:")
Key = input("enter a key from 1-100:")
for Letter in message:
Char = ord(Letter)
if (Char + Key) < 32:
encryptedChar = ((Char - Key) + 127) - 32
else:
encryptedChar = (Char - Key)
sys.stdout.write(chr(encryptedChar))
print(encryptedChar,end=" ")
我当前收到错误:
TypeError: unsupported operand type(s) for +: 'int' and 'str')
input
是字符串,需要转换为整数。你知道吗转换为int后,代码运行良好:
相关问题 更多 >
编程相关推荐