isdisjoint
判断两个集合是否包含相同的元素,如果没有返回True,否则返回false
用法
a_set.isdisjoint(b_set)
参数
b_set 与当前集合用来判断的集合
a_set = {3, 4, 5, 'a', 'b'}
b_set = {3, 4, 5, 6}
c_set = {'c'}
print(a_set.isdisjoint(b_set))
print(a_set.isdisjoint(c_set))
结果
False
True
判断两个集合是否包含相同的元素,如果没有返回True,否则返回false
a_set.isdisjoint(b_set)
b_set 与当前集合用来判断的集合
a_set = {3, 4, 5, 'a', 'b'}
b_set = {3, 4, 5, 6}
c_set = {'c'}
print(a_set.isdisjoint(b_set))
print(a_set.isdisjoint(c_set))
结果
False
True