如何在变量python中放入

2024-04-25 15:27:38 发布

您现在位置:Python中文网/ 问答频道 /正文

我最近一直在尝试做一个加密程序,我不太明白如何在一个变量中放置双引号,在这个例子中是“字母表”。目前我有每一个字符,我需要除了“和一个标签键,请记住我只是一个初学者和帮助将不胜感激。-谢谢!你知道吗

while True:
    plaintext = input('Enter messege: ')
    alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.,!?#@$%^&*()-_=+[]{}|\:;`~<>/ '" 
    key = not telling you what I am
    cipher = ''
    for c in plaintext:
       if c in alphabet:
            cipher += alphabet[(alphabet.index(c)+key)%(len(alphabet))]

    print ('your encrypted message is: ' + cipher)

Tags: keyin程序trueinput标签字符字母表