我没有使用python pyperclip模块获得任何输出,我不知道问题出在哪里?

问题描述 投票:0回答:1
import  pyperclip

#Cesar Chiper
#The String to be encrypt or decrypted

message = "This is my secret message"

#The encryption /decryption key

key = 13

#Tell the program to encrypt/decrypt
mode = "encrypt"

#Every possible sympol to encrypt or decrypt from the message

letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

#Stores message

translated=""

message = message.upper()

#run the encryption/decryption code in each symbol in the message string

for symbol in message:
  if symbol in letters:
    #get the encypted or deycrypted number for this symbol
    num = letters.find(symbol)
    if mode == "encrypt":
      num = num + key
    elif mode == "decrypt":
      num = num - key

      #handle the wrap around if num is larger than lenght of letters or less than 0

      if num >= len(letters):
        num = num - len(letters)
      elif num < 0:
        num = num + len(letters)

#ad encrypted/decrypted number symbol at the end of translted
        translated = translated + letters[num]

      else:

  #Just add the symbol without encrypting/decrypting
       translated = translated + symbol

#print the encrypted/decrypted to screen
print(translated)

  #copy the encrypted/decrypted string to clipoard
pyperclip.copy(translated)

python python-3.x list encryption python-module
1个回答
0
投票

Hei。我发现您的代码中只有indent

© www.soinside.com 2019 - 2024. All rights reserved.