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







]*>.*?底下插入一個圖檔.*?</w:p>’, flags = re.DOTALL) ; new_xml, n = pattern.subn(”, xml, count=1)' title='Python正則替換:全面掌握 re.sub 與 re.subn 的差異與實戰 #substitute(替換); . 預設匹配「除\n以外的任意單一字元」; pattern = re.compile(r'<w:p[^>]*>.*?底下插入一個圖檔.*?</w:p>’, flags = re.DOTALL) ; new_xml, n = pattern.subn(”, xml, count=1)' loading='lazy' width=350 height=233 />

近期留言