我的代码[仅与'EncryptString'函数有关”:
from tkinter import *
import time
c = ["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""]
nc = ["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""]
al = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
at = ["b","m","f","s","c","v","e","l","d","n","t","a","w","g","p","o","r","q","k","h","u","x","i","y","j","z"]
def GoE():
EnteredText = (e1.get())
if EnteredText != ".!entry":
print("Encrypting")
#try:
print(EnteredText, e1)
print("Attempting to Encrypt")
EnteredText.lower()
c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], c[8], c[9], c[10], c[11], c[12], c[13], c[14], c[15], c[16], c[17], c[18], c[19], c[20], c[21], c[22], c[23], c[24], c[25], c[26], c[27], c[28], c[29], c[30], c[31] = EnteredText
EncryptString()
def Encrypter():
print("Encrypter Selected")
screen2.title("Encrypter")
a = Label(screen2, text="Text to be Encrypted (SUM OF CHARACTERS MUST BE 32)").grid(row=1, column=0)
e1.grid(row=2, column=0)
button2 = Button(screen2, text="Enter", command=GoE).grid(row=3, column=0)
def EncryptString():
count = 0
letterPos = 0
poo = 0
print('1')
test2 = 0
while test2 <= 31:
print(c[test2])
test2 = test2 + 1
time.sleep(10)
while poo <= 31:
while count <= 31:
print(str(count))
if c[count] == al[letterPos]:
nc[count] = at[letterPos]
print('1.3')
print(nc[count])
else:
if letterPos == 25:
print('Alphabet Completed')
letterPos = 0
else:
letterPos = letterPos + 1
print('1.2')
count = count + 1
print('Count = ' + str(count))
count = 0
poo = poo + 1
test = test + 1
num = 0
while num <= 31:
print(nc[num])
num = num + 1
MenuScreen()
引起错误的主线是:
while poo <= 31:
while count <= 31:
print(str(count))
if c[count] == al[letterPos]:
nc[count] = at[letterPos]
print('1.3')
print(nc[count])
else:
if letterPos == 25:
print('Alphabet Completed')
letterPos = 0
else:
letterPos = letterPos + 1
print('1.2')
count = count + 1
print('Count = ' + str(count))
count = 0
poo = poo + 1
test = test + 1
我个人认为这与以下方面有关:
if c[count] == al[letterPos]:
nc[count] = at[letterPos]
它应该加密32个字符的文本,并在最后打印它们。 我要加密的文本是“ abcdefghijklmnopqrstuvwxyzssssssss”,它将加密“ a”并打印“ b”,并将加密“ ssssss”,并输出“ kkkkkk”。其余的只是打印为''(空白)。您可以使用任何代码补丁来尝试检测问题。 我已经尝试发现问题几天了,但无法解决。将不胜感激。我不知道我是在错误地对待它还是只是有点愚蠢。重新启动它可能会更容易。我认为我不会循环/循环太多,并且每个输入的字符只能循环显示一个字母。我的问题基本上是,我在正确的路线上吗?并进行任何改进以使其起作用?