1
爲什麼不能使用子集運算符< =?來比較集合和ImmutableSet?例如。運行以下代碼。這裏有什麼問題?任何幫助讚賞。我正在使用Python 2.7。爲什麼我不能比較Python 2.7中的集合和immutableset
>>> from sets import ImmutableSet
>>> X = ImmutableSet([1,2,3])
>>> X <= set([1,2,3,4])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sets.py", line 291, in issubset
self._binary_sanity_check(other)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sets.py", line 328, in _binary_sanity_check
raise TypeError, "Binary operation only permitted between sets"
TypeError: Binary operation only permitted between sets
>>>