1
我正在使用python獲取用戶輸入,然後使用正則表達式我想檢查某些單詞。在這種情況下,我想檢查用戶的感受,然後將其存儲在列表中。問題是,當我打印清單時,它是空的。使用正則表達式查找一組單詞
import re
phrase = raw_input("How are you feeling ")
phrase = phrase.lower()
feel=(re.findall(r^(?=.*\bsad\b)(?=.*\bhappy\b)(?=.*\bjoyful\b)(?=.*\bmad\b)(?=.*\bsad\b), phrase))
print feel
謝謝。這工作。 – danilo 2014-09-06 18:40:14
謝謝,請接受我的回答;) – 2014-09-06 18:41:21