我决定为Unicode编写某种用于测试目的的秘密代码。
我已经通过在Unicode中添加数字来做到这一点,所以这将是一个秘密。
我一直在收到此错误,但是我不知道如何解决它。
有什么解决办法吗?
原始码
message = input("Enter a message you want to be revealed: ")
secret_string = ""
for char in message:
secret_string += str(chr(char + 7429146))
print("Revealed", secret_string)
q = input("")
原始错误
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-182-49ece294a581> in <module>
2 secret_string = ""
3 for char in message:
----> 4 secret_string += str(chr(char + 7429146))
5 print("Revealed", secret_string)
6 q = input("")
TypeError: can only concatenate str (not "int") to str
更新的代码
while True:
try:
message = int(input("Enter a message you want to be decrypt: "))
break
except ValueError:
print("Error, it must be an integer")
secret_string = ""
for char in message:
secret_string += chr(ord(char - str(742146)))
print("Decrypted", secret_string)
q = input("")
慕容森
撒科打诨
慕婉清6462132
忽然笑
qq_花开花谢_0
相关分类