python tkinter中的缩进问题
我在做一个假黑客程序。它应该运行用户选项并报告一些有趣的结果。然而,我收到一个缩进问题。我的代码是:python tkinter中的缩进问题,python,indentation,Python,Indentation,我在做一个假黑客程序。它应该运行用户选项并报告一些有趣的结果。然而,我收到一个缩进问题。我的代码是: from tkinter import * import time import random print("") def runresults(): print("") def hackthem(): text.delete(0.0, END) global email global inbox global searchhistory g
from tkinter import *
import time
import random
print("")
def runresults():
print("")
def hackthem():
text.delete(0.0, END)
global email
global inbox
global searchhistory
global files
global applications
global password
email = entry.get()
choice_1 = var1.get()
if choice_1 == 1:
inbox = ("yes")
else:
inbox = ("no")
choice_2 = var2.get()
if choice_2 == 1:
searchhistory = ("yes")
else:
searchhistory = ("no")
choice_3 = var3.get()
if choice_3 == 1:
files = ("yes")
else:
files = ("no")
choice_4 = var4.get()
if choice_4 == 1:
applications = ("yes")
else:
applications = ("no")
choice_5 = var5.get()
if choice_5 == 1:
password = ("yes")
else:
password = ("no")
text.insert(END, "Hacking... (please wait for up to 20 secs)") #Issue here
time.sleep(9)
runresults()
def start():
global text
global var1
global var2
global var3
global var4
global var5
global window
window = Tk()
window.title("Let's Hack!")
label = Label(window, text="Enter Email address (of person you want to hack): ")
label.grid(row=0, column=0, sticky=W)
global entry
entry = Entry(window, width=41, bg="light green")
entry.grid(row=1, column=0, sticky=W)
entry.insert(END, "someone@somemail.com/co.uk/org")
var1 = IntVar()
global c1
c1 = Checkbutton(window, text="Inbox", variable=var1)
c1.grid(row=2, column=0, sticky=W)
var2 = IntVar()
global c2
c2 = Checkbutton(window, text="Search History", variable=var2)
c2.grid(row=3, column=0, sticky=W)
var3 = IntVar()
global c3
c3 = Checkbutton(window, text="Files", variable=var3)
c3.grid(row=4, column=0, sticky=W)
var4 = IntVar()
global c4
c4 = Checkbutton(window, text="Applications", variable=var4)
c4.grid(row=5, column=0, sticky=W)
var5 = IntVar()
global c5
c5 = Checkbutton(window, text="Password", variable=var5)
c5.grid(row=6, column=0, sticky=W)
button = Button(window, width=7, text="HACK", command=hackthem)
button.grid(row=7, column=0, sticky=W)
text = Text(window, width=90, height=20, background="yellow")
text.grid(row=8, column=0, columnspan=6, sticky=W)
start()
对不起,代码有点长,我已经用注释标记了问题区域。
我得到一个错误:
未缩进与任何外部缩进级别不匹配
问题在哪里?我确信没有语法错误。
我看不出缩进问题在哪里。请看第一行,前面有额外的空间 从tkinter进口*
此外,text.insert没有正确的缩进 只需在前面添加1个空格,3个空格代替4个它会告诉您这是一个缩进错误。text.insertEND,Hacking。。。请在这里等待20秒,这里只有三个空格。谢谢。我没有注意到。只是错过了。