1
解析字符串變量所以我有這樣的關鍵字的數組配套設置的關鍵字從JSON
keyword = ['Bob','hello','boot']
我解析JSON,抓住字符串值,命名爲標題,並輸入名稱。
標題包含字符串,如「鮑勃哎,你好啓動」
我想使它所以如果標題/名稱包含了所有從關鍵字數組列表的話,方案將返回唯一的真實。
目前,我有這樣的代碼
keyword = ['Bob','hello','boot']
name=str(item[u'title'].encode('ascii','ignore')) #grab Title and input into name
found_a_string = True
for word in keyword:
if not word in name.lower():
found_a_string = False
if found_a_string:
ID=str(item[u'id'])
print name, ID, 'found' #would output full title and then assoicated ID from json.
但代碼真正的回報,只要從關鍵字matche一家之言。
任何幫助,將不勝感激。
感謝
的可能的複製http://stackoverflow.com/questions/12999930/string-contains-all-the-elements-of-a-list – 2016-11-29 08:51:32