find python 中的功能出现故障或无法正常工作,或者我遗漏了什么?

find function in python malfunctioning or not working, or am I missing something?

嗨,我正在尝试创建一个按钮,根据它在文本中找到的内容来启动脚本 对不起,如果这个问题很难理解。

脚本(为了更简单的例子我会缩短它):

import Tkinter as *
window = Tk()

#locals

Depended = 1    #this is what depends on what script it will start
Active = False  #this will start the script

#commands
def check():
    global Depended

    text = scrolltext.get("1.0", "end") #scrolltext is basically like a tkinter text

    find_AutoFishing = text.find("AutoFishing")
    find_HoldClick = text.find("HoldClick")   #what its looking for
    find_SpamClick = text.find("SpamClick")

    if find_AutoFishing:
        print("found autofish")
        Depended = 10
    elif find_HoldClick:
        print("found holdclick") #what it found
        Depended = 20
    elif find_SpamClick:
        print("found spamclick")
        Depended = 30
    else:
        print("nothing found") 

def Start():
    global Active
    check()        #this will start the script
    Active = True

    t = Thread (target=ATTACK)
    t.start()


def Stop():
    global Active
    global Depended #this will end the script
    Active = False
    Depended = 1


#scrolltext works the same as Text in Tkinter
scrolltext = scrolledtext.ScrolledText(window, height=11, width=60, bg="#050505", fg="white", bd=0)
scrolltext.pack()

execute_button = Button(main, command=Start)
execute_button.pack()

purge_button = Button(main, command=Stop)
purge_button.pack()

window.mainloop()

基本上,我 运行 遇到的问题是当我的滚动文本中有单词“SpamClick”时 然后按执行,检查功能将不起作用并且不会检测到 SpamClick 所在的工作 滚动文本,但不是打印“Depended = 1”,而是打印类似“Depended = 20”的内容。

再次抱歉,如果这个脚本很难理解,请不要在这个问题上花太多时间,因为我可能很快就会找到解决方案,因为这是我目前的主要项目。

好的,我找到问题了,

当我说

find_AutoFishing = text.find("AutoFishing")
find_HoldClick = text.find("HoldClick")   #what its looking for
find_SpamClick = text.find("SpamClick")

if find_AutoFishing:
    print("found autofish")
    Depended = 10
elif find_HoldClick:
    print("found holdclick") #what it found
    Depended = 20
elif find_SpamClick:
    print("found spamclick")
    Depended = 30
else:
    print("nothing found")

我想说的是:

if "AutoFishing in text:
    print("AutoFishing")
    Depended = 10

主要是我没把功能说对,还是谢谢了 看到这个的任何人:)