我如何在不破坏机器人的情况下 运行 一个程序?

How would I run a program while not breaking the bot?

因此,正如下面的代码所示,我希望能够在说出某个短语时让我的机器人 运行 成为第二个 python 程序。比如

can you start a webcam bot?

等等。我只需要调用 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

如果有人可以提供帮助,请 post 代码和一些网站,我可以进一步了解该主题。谢谢。

这个 hack 将满足您的需求

os.system("python otherfile.py")