我有一个功能,可以打印25行文本,我需要在tkinter页面中输入,但每次都不起作用
我试过使用text.input,但似乎不起作用
这是我需要打印的函数:
def decode(secretmessage):
for key in range(len(alphabet)):
newAlp = alphabet[key:] + alphabet[:key]
attempt = ""
for i in range(len(message)):
index = alphabet.find(message[i])
if index < 0:
attempt += message[i]
else:
attempt += newAlp[index]
print("Key: " + str(key) + " - " + attempt)
print()
这就是我所尝试的:
def finalprint (uncoded):
print("Key: " + str(key) + " - " + attempt)
print()
text = Text.insert(root, finalprint(message), width=450, height=450)
因为某种原因出现是行不通的
print
命令将给定的文本打印到控制台。它确实返回None
您的
finalprint
函数还返回None
,而Text.insert
需要一个字符串作为输入您可以将值存储到字符串中,而不是打印输出
然而,finalprint函数的输入是未编码的,而其中使用的变量是键和尝试。您可能需要向函数传递更多信息,使其像您编写的那样工作
相关问题 更多 >
编程相关推荐