code:
ask = ["您好嗎", "你是誰"]
ans = ["我很好", "我是聊天機器人"]
while True:
ask_input = input("請輸入你的問題(Q or q to exit):\t")
if ask_input.lower() == "q":
break
if ask_input in ask:
idx = ask.index(ask_input)
print(ans[idx])
輸出結果:
做出簡單版aiml 模組的效果
推薦hahow線上學習python: https://igrape.net/30afN