>>> s={‘s‘,‘s‘,‘t‘} >>> s {‘s‘, ‘t‘} >>> type(s) <class ‘set‘> >>> >>> s=set([1,2,3,4,5,6,7]) >>> s {1, >>> dir(set()) [‘__and__‘, ‘__class__‘, ‘__contains__‘, ‘__delattr__‘, ‘__dir__‘, ‘__doc__‘, ‘__eq__‘, ‘__format__‘, ‘__ge__‘, ‘__getattribute__‘, ‘__gt__‘, ‘__hash__‘, ‘__iand__‘, ‘__init__‘, ‘__init_subclass__‘, ‘__ior__‘, ‘__isub__‘, ‘__iter__‘, ‘__ixor__‘, ‘__le__‘, ‘__len__‘, ‘__lt__‘, ‘__ne__‘, ‘__new__‘, ‘__or__‘, ‘__rand__‘, ‘__reduce__‘, ‘__reduce_ex__‘, ‘__repr__‘, ‘__ror__‘, ‘__rsub__‘, ‘__rxor__‘, ‘__setattr__‘, ‘__sizeof__‘, ‘__str__‘, ‘__sub__‘, ‘__subclasshook__‘, ‘__xor__‘, ‘add‘, ‘clear‘, ‘copy‘, ‘difference‘, ‘difference_update‘, ‘discard‘, ‘intersection‘, ‘intersection_update‘, ‘isdisjoint‘, ‘issubset‘, ‘issuperset‘, ‘pop‘, ‘remove‘, ‘symmetric_difference‘, ‘symmetric_difference_update‘, ‘union‘, ‘update‘] >>> ‘add‘添加, ‘clear‘清空, ‘copy‘复制, ‘difference‘差异(清除), ‘difference_update‘清除更新, ‘discard‘移除, ‘intersection‘交集, ‘intersection_update‘交集更新, ‘isdisjoint‘无交集, ‘issubset‘子集, ‘issuperset‘父集, ‘pop‘移除, ‘remove‘移除, ‘symmetric_difference‘差集, ‘symmetric_diffeence_update‘减, ‘union‘并集, ‘update‘更新 add(self, *args, **kwargs): >>> s=set() >>> s.add(‘gg‘) >>> s {‘gg‘} >>> clear(self, *args, **kwargs): >>> s={‘a‘,‘g‘} >>> s {‘g‘, ‘a‘} >>> s.clear() >>> s set() >>> copy(self, *args, **kwargs): >>> s={‘s‘} >>> s1=s.copy() >>> s1 {‘s‘} >>> difference(self, *args, **kwargs): >>> s0={"a",‘b‘,‘c‘} >>> s1={‘b‘,‘c‘,‘d‘} >>> s0 {‘c‘, ‘a‘, ‘b‘} >>> s1 {‘c‘, ‘d‘, ‘b‘} >>> s0.difference(s1) {‘a‘} >>> difference_update(self, *args, **kwargs): >>> s0={"a",‘b‘,‘c‘} >>> s1={‘b‘,‘c‘,‘d‘} >>> s0.difference_update(s1) >>> s0 {‘a‘} discard(self, *args, **kwargs): >>> s=set(‘agsgasf‘) >>> s {‘s‘, ‘g‘, ‘a‘, ‘f‘} >>> s.discard(‘s‘) >>> s {‘g‘, ‘a‘, ‘f‘} >>> intersection(self, *args, **kwargs): >>> s {‘g‘, ‘a‘, ‘f‘} >>> s.intersection(set(‘afh‘)) {‘a‘, ‘f‘} >>> intersection_update(self, *args, **kwargs): >>> s {‘g‘, ‘a‘, ‘f‘} >>> s.intersection_update(set(‘afh‘)) >>> s {‘a‘, ‘f‘} >>> isdisjoint(self, *args, **kwargs): >>> s {‘a‘, ‘d‘, ‘s‘, ‘f‘} >>> s.isdisjoint(‘c‘) True >>> issubset(self, *args, **kwargs): >>> s {‘a‘, ‘d‘, ‘s‘, ‘f‘} >>> s.issubset(‘adsfg‘) True >>> issuperset(self, *args, **kwargs): >>> s {‘a‘, ‘d‘, ‘s‘, ‘f‘} >>> s.issuperset(‘a‘) True >>> pop(self, *args, **kwargs): >>> s {‘a‘, ‘d‘, ‘s‘, ‘f‘} >>> s.pop() ‘a‘ >>> s {‘d‘, ‘s‘, ‘f‘} >>> remove(self, *args, **kwargs): >>> s {‘d‘, ‘s‘, ‘f‘} >>> s.remove(‘s‘) >>> s {‘d‘, ‘f‘} >>> symmetric_difference(self, *args, **kwargs): >>> s {‘a‘, ‘s‘, ‘f‘} >>> s.symmetric_difference(‘s‘) {‘a‘, ‘f‘} >>> symmetric_difference_update(self, *args, **kwargs): >>> s {‘s‘, ‘f‘} >>> s.symmetric_difference_update(‘s‘) >>> s {‘f‘} >>> union(self, *args, **kwargs): >>> s {‘f‘} >>> s.union(‘sfsghj‘) {‘h‘, ‘s‘, ‘f‘, ‘j‘, ‘g‘} >>> update(self, *args, **kwargs): >>> s=set(‘abc‘) >>> s.update(‘bd‘) >>> s {‘a‘, ‘d‘, ‘b‘, ‘c‘} >>>
时间: 2024-10-15 08:35:39