如果集合A的所有元素都占用作为参数传递的集合B,则issuperset()方法返回True,如果集合A中的所有元素都不存在,则返回false。
这意味着如果A是B的超集,则它返回true;否则,它返回true。否则错
用法:
A.issuperset(B) checks whether A is a superset of B or not.
返回值:
True if A is a superset of B; otherwise false.
代码1:
# Python program to demonstrate working of
# issuperset().
A = {4, 1, 3, 5}
B = {6, 0, 4, 1, 5, 0, 3, 5}
print("A.issuperset(B):", A.issuperset(B))
# B is superset of A
print("B.issuperset(A):", B.issuperset(A))
输出:
A.issuperset(B): False B.issuperset(A): True
代码2:
# Python program to demonstrate working
# of issuperset().
A = {1, 2, 3}
B = {1, 2, 3, 4, 5}
C = {1, 2, 4, 5}
print("A.issuperset(B):", A.issuperset(B))
print("B.issuperset(A):", B.issuperset(A))
print("A.issuperset(C):", A.issuperset(C))
print("C.issuperset(B):", C.issuperset(B))
输出:
A.issuperset(B): False B.issuperset(A): True A.issuperset(C): False C.issuperset(B): False
相关用法
注:本文由纯净天空筛选整理自Mohit Gupta_OMG 大神的英文原创作品 issuperset() in Python。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。