两个集合求交集

check_set_list = ['zheng','xinying','zhang']
>>> sample_set_list = ['xinying','zhangchunmei','zhiwu']
>>> check_set_list & sample_set_list  # &求交集必须对集合进行操作


Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for &: 'list' and 'list'


>>> set(check_set_list) & set(sample_set_list)
{'xinying'}

 

posted @ 2020-06-01 08:29  像阳光,像春天  阅读(324)  评论(0编辑  收藏  举报