python tkinter 中的缩进问题

Indent issue in python tkinter

我正在制作一个假的黑客程序。它应该 运行 用户选项并报告一些有趣的结果。但是我收到了缩进问题。我的代码是:

 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()

(抱歉代码有点长)我已经在问题区进行了评论。 我收到错误:

unindent does not match any outer indentation level

问题出在哪里?我确信没有语法错误。 我看不出缩进问题在哪里。

看第一行,在from

之前多出space

from tkinter import *

此外,text.insert 没有正确的缩进。

只需在前面添加 1 space(3 space 代替 4)