0
我正在編寫一個代碼,用於加密用戶在python中輸入的消息。我通過用戶輸入的數字來移動消息。但是,當我打印它時,空格被隨機符號所替代。當我嘗試打印郵件時,它會打印一個隨機符號而不是空格
print("""Welcome to the Encryption 'machine'""")
message=input('Please enter a message you wish to be encrypted ')
shift_num=int(input('Please enter the number that you wish to shift your message by'))
for value in message:
value=ord(value)
value=value+shift_num
value=chr(value)
value=value.replace(' ', '')
print(value, end='')
這是發生了什麼:
Welcome to the Encryption 'machine'
Please enter a message you wish to be encrypted: aaa bbb
Please enter the number that you wish to shift your message by: 2
ccc"ddd