我已经通过Stackoverflow和其他网站使用谷歌机器上的线程进行搜索,没有什么让我相当我在找什么。
我是使用Python 3的新编程学生,所以我的大部分东西都非常基础。
我正在编写一个程序,允许我使用Caeser密码来加密和解密文本文件。从用户处获取一个短语并应用给定的轮班用户。
这就是我现在正在处理的事情:
有些代码只是作为一个占位符,直到我进入我的程序。
import string
print ("1) Encrypt")
print ("2) Decrypt")
print ("3) Decrypt w/o Shift")
Choice = input("Choice: ")
if Choice == '1':
message = input("Message: ")
shift = int(input("Shift: "))
newmsg = ''
for char in message:
if char.isupper():
new = (ord(char)-ord('A')) + shift
newmsg = chr(new+ord('A'))
print (newmsg, end="")
else:
print(" ")
elif Choice == '2':
print ("2")
elif Choice == '3':
print ("3")当我输入一个测试短语时,如“THIS IS A TEST”,它给了我输出和正确的加密,但是它显示如下:
V
J
K
U
K
U
C
V
G
U
B这是2的“转变”
如果我将end = ' '添加到我的打印语句中,它会输出为:
V J K U
K U
C
V G U V如果我将end = ''添加到我的打印语句中,它会输出为:
VJKU
KU
C
VGUV我正在寻找输出:
VJKU KU C VGUV我知道这是我忽略的一些愚蠢的东西。任何帮助,将不胜感激。非常感谢。