-3
我有這個,但它做的部分匹配:字匹配在Python
for il in ignore_list:
if il.word in title or il.word in text:
return True
如何我只能全字匹配?
我有這個,但它做的部分匹配:字匹配在Python
for il in ignore_list:
if il.word in title or il.word in text:
return True
如何我只能全字匹配?
您需要您的標題和文本字符串分割成單詞表:
if il.word in title.split() or il.word in text.split():
不錯,簡潔! – Floris 2013-04-21 23:45:16
正是我在找什麼,謝謝。 – 2013-04-21 23:56:20
給正在發生的事情的一個例子,並且要發生什麼。 「文本」和「標題」是什麼樣的? – Floris 2013-04-21 23:43:11