我需要使用正則表達式和 Collection 找到多個匹配項(包含在列表中)。我試過這段代碼,但它顯示空字典:some_words_lst = ['caT.', 'Cat', 'Dog', 'paper', 'caty', 'London', 'loNdon','londonS']words_to_find = ['cat', 'london']r = re.compile('(?:.*{})'.format(i for i in words_to_find),re.IGNORECASE)count_dictionary = {}for item in some_words_lst: if r.match(item): count_dictionary['i']+=1print(count_dictionary)感謝幫助!
查看完整描述