因此,代码如下所示,我希望能够让我的机器人运行第二个python程序,当说某个短语时。如
你可以开始使用网络摄像头吗?
等。我只需要一些用脚本调用python文件的东西,就像我说的那样,不要让机器人关闭。
代码如下
from chatterbot import ChatBot
from chatterbot.training.trainers import ChatterBotCorpusTrainer
# Create a new instance of a ChatBot
bot = ChatBot("NOSTAW",
storage_adapter="chatterbot.adapters.storage.JsonDatabaseAdapter",
logic_adapters=[
"chatterbot.adapters.logic.MathematicalEvaluation",
"chatterbot.adapters.logic.TimeLogicAdapter",
"chatterbot.adapters.logic.ClosestMatchAdapter"
],
input_adapter="chatterbot.adapters.input.TerminalAdapter",
output_adapter="chatterbot.adapters.output.TerminalAdapter",
database="../SecondaryDataBase.json"
)
bot.set_trainer(ChatterBotCorpusTrainer)
# Train the chat bot with the entire english corpus
bot.train("chatterbot.corpus.english")
print("Type thoughts to bot.")
# The following loop will execute each time the user enters input
while True:
try:
# We pass None to this method because the parameter
# is not used by the TerminalAdapter
bot_input = bot.get_response(None)
# Press ctrl-c or ctrl-d on the keyboard to exit
except (KeyboardInterrupt, EOFError, SystemExit):
break
如果有人可以提供帮助,请发布代码,有些网站我可以进一步了解这个主题。谢谢。
答案 0 :(得分:2)
这个黑客会做你正在寻找的东西
os.system("python otherfile.py")