Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 简单聊天机器人中的错误_Python_Artificial Intelligence_Chatbot - Fatal编程技术网

Python 简单聊天机器人中的错误

Python 简单聊天机器人中的错误,python,artificial-intelligence,chatbot,Python,Artificial Intelligence,Chatbot,我是python新手,当您执行这段代码时,无论您对“您的一天过得怎么样?”的回答是什么,它都会以“很好”作为响应。我做错了什么 import random yes = ['yes', 'Yes', 'Yeah', 'yeah', 'Yea', 'yea', 'Mhmm', 'mhmm', 'Mhm', 'mhm'] no = ['No', 'no', 'Nah', 'nah'] good = ['Good', 'good', 'Great', 'great', 'Okay', 'okay',

我是python新手,当您执行这段代码时,无论您对“您的一天过得怎么样?”的回答是什么,它都会以“很好”作为响应。我做错了什么

import random

yes = ['yes', 'Yes', 'Yeah', 'yeah', 'Yea', 'yea', 'Mhmm', 'mhmm', 'Mhm', 'mhm']
no = ['No', 'no', 'Nah', 'nah']
good = ['Good', 'good', 'Great', 'great', 'Okay', 'okay', 'Ok', 'ok', 'OK']
bad = ['Bad', 'bad', 'Not good', 'not good', 'Not well', 'not well']

random_yes = random.choice(yes)
random_no = random.choice(no)
random_good = random.choice(good)
random_bad = random.choice(bad)

greetings = ['Hola', 'Hello', 'Hi', 'Hey!','hey...']
random_greeting = random.choice(greetings)

print(random_greeting)

name = input('What is your name?')
print('Hello', name,)

question1 = ['How are you?','How are you doing?','How is your day?','How is your day going?']
random_question1 = random.choice(question1)

ur1 = input(random_question1)

if good in ur1:
    print("That's good")
elif bad in ur1:
    print("I'm sorry")
else:
    print("I don\'t understand")

如果else条件错误,则您正在字符串中搜索列表
good
ur1

代码应该是

if ur1 in good:
    print("That's good")
elif ur1 in bad:
    print("I'm sorry")
else:
    print("I don\'t understand")

如果else条件错误,则您正在字符串中搜索列表
good
ur1

代码应该是

if ur1 in good:
    print("That's good")
elif ur1 in bad:
    print("I'm sorry")
else:
    print("I don\'t understand")