与while循环中的if语句进行AI多输入对话不起作用?

时间:2016-09-18 22:23:59

标签: python string python-3.x if-statement while-loop

我的AI我正在制作一个while循环中的作品,如果我想要它的所有内容的语句,例如:

`while 1:



lis = ("im bored","game","im board","what do you want to do","what should we do","rage","i","I","smashed","broke","destroyed","cracked","grounded","detention","in trouble","nothing","not much","erics number","date","time","no","nope","nah","not","yes","yep","yeah","in deed","bye","gtg","got to go","see you","c u","hi","hello","hello","hia","fuck","crap","shit","bleep","omg","OMG","oh my god","","","","","","look up","email","map","add Note","get Note","joke","rabid donkey","game","quit","help","raging","hurt","fire","","thanos","erics mad","danger","sad","upset","","","creator","thanks","lol","ok","k","yep","report","owner","maker","jarvis","coder","thank you","sup","whats up","what's up","hey","hah")

resp2 = input("")

esa = ""
for word in lis:
    if word in resp2:
       esa = word

    if esa in ("quit","bye","gtg","got to go","see you","c u"):
            byebro = random.choice(("ok bye Sergei cu later","bye sir","c u later sir","talk to you later then","talk to you later"))
            print (byebro)
            os.system("say '"+byebro+"'")
            exit()

    if esa in ("look up","web search","search the web for"):

            c = random.choice(("ok","lets see","let me see","ok sir il get right on that lets see","im looking up and i dont see anything??"))
            print (c)
            c1 = ("sorry an error has acurred package missing")
            print (c1)

            os.system("say '"+c+"'")
            os.system("say '"+c1+"'")
            break


    if esa == "add note":
            d = random.choice(("ok sir one sec il pull up the note pad","ok sir one sec","yeah one sec il pull it up","one sec sir","ok","ok sir"))
            print (d)
            os.system("say '"+d+"'")
            note1 = input("")
            notes.append(note1)
            break

    if esa == "get note":
            e = random.choice(("ok sir one sec il pull up the your recent notes","ok sir one sec","yeah one sec il pull it up","one sec sir","ok","ok sir notes","ok sir"))
            print (e)
            os.system("say '"+e+"'")
好的,所以有数百个if语句,但我希望能够像这样与jarvis交谈。在哪里我可以说些什么然后他会问我关于它然后我会回答然后他回答然后它突破if语句并再次循环和所有if语句。

我:我是基于jarvis的

贾维斯:你做了什么?

我:我砸了一个窗户

贾维斯:哦好的

所以我希望代码看起来像这样,但它不起作用

if esa in ("im grounded","im in trouble","i got detention"):
    print "your always getting in trouble its like second nature to you"
    esa3 = input("what did you do")
if esa3 in ("i broke something","i smashed something"):
    print "your always breaking stuff"

1 个答案:

答案 0 :(得分:0)

我想通了你需要在if语句中放入一个if语句

java.lang.IllegalStateException: Cannot call this method while RecyclerView is computing a layout or scrolling