目录
1.isdisjoint的功能
2.isdisjoint的用法
3.代码
1.isdisjoint的功能
判断两个集合是否包含相同的元素。如果没有,返回True;如果有,返回False。
2.isdisjoint的用法
a_set = {'name','xiaomu','xiaoming'}
b_set = {'xiaoming','xiaogang','xiaohong'}
result = a_set.isdisjoint(b_set)
print(result)
运行结果:
False
3.代码
# coding:utf-8
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))
运行结果:
/Users/llq/PycharmProjects/pythonlearn/pythonlearn/python_set/bin/python /Users/llq/PycharmProjects/pythonlearn/python_set/set_isdis.py
False
False
True
True进程已结束,退出代码为 0