在 Python 中,是否有一个集合可以有效地充当包含所有可能集合的集合?
最佳答案
你可以继承set
:
class FullSet(set):
def __contains__(self, item):
return True
fullset = FullSet()
print({1, 2, 3} in fullset)
输出:
True
关于python - 是否存在 "in"始终返回 true 的集合?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40169107/