目录
- isdisjoint的功能
- isdisjoint的用法
isdisjoint的功能
- 判断两个集合是否包含相同的元素,如果没有返True ,否则返回False
isdisjoint的用法
- 用法:
a_set.isdisjoint(b_set) - 参数:
b_set : 与当前集合用来判断的集合 - 返回值: 返回一个布尔值 True 或 False
In [57]: a_set = { 'name', 'xiaomu' , 'xiaoming' }
In [58]: b_set = { 'xiaoming' , 'xiaogang', 'xiaohong ' }
In [59]: result = a_set.isdisjoint(b_set)
In [60]: result
Out[60]: False
实战
company_not_allow = {'女', '喝酒', '抽烟', '睡懒觉'}
one_player = {'男', '跑步', '朝气', '喝酒'}
two_player = {'女', '生活规律', '跆拳道'}
three_player = {'男', '太极拳'}
four_player = {'男', '空手道', '年轻'}
print(company_not_allow.isdisjoint(one_player))
print(company_not_allow.isdisjoint(two_player))
print(company_not_allow.isdisjoint(three_player))
print(company_not_allow.isdisjoint(four_player))
False
False
True
True
Process finished with exit code 0
|