0

我在 Chatterbot 的文档网站上看到了一些示例代码

from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer

# Create a new chat bot named Charlie
chatbot = ChatBot('Charlie')

trainer = ListTrainer(chatbot)

trainer.train([
    "Hi, can I help you?",
    "Sure, I'd like to book a flight to Iceland.",
    "Your flight has been booked."
])

# Get a response to the input text 'I would like to book a flight.'
response = chatbot.get_response('I would like to book a flight.')

print(response)

是否有可能告诉机器人从终端启动命令而不发布字符串答案?

4

1 回答 1

2

input如果您有 python3 或raw_inputpython2 ,请使用

while True:
    question = input("")
    response = chatbot.get_response(question)
    print(response)
于 2019-04-14T16:09:46.190 回答