no message

This commit is contained in:
陈银军
2025-12-10 16:31:05 +08:00
parent 18c2a6b460
commit 2d3c18b213
2 changed files with 10 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
A = {1, 2}
B = {1, 2, 3, 4}
print(A.issubset(B)) # A是B的子集
print(B.issuperset(A)) # B是A的超级
print(A.isdisjoint(B)) # A 和 B 有交集;若无交集则返回 True
+5
View File
@@ -0,0 +1,5 @@
# 如果你需要一个不可变的集合(例如作为字典的键),可以使用 frozenset
fs = frozenset([1,2,3,4,5,6])
B = {1, 2, 3, 4}
print(fs)
print(len(fs))