python-set(集合)类官方文档翻译

北城以北 提交于 2020-02-25 20:30:47

这是help(set)生成的官方文档的翻译,若有误,请留言

Help on class set in module builtins:

class set(object)
 |  set() -> new empty set object       #创建空集合
 |  set(iterable) -> new set object     #通过可迭代对象创建集合
 |  
 |  Build an unordered collection of unique elements.
 #  集合是一组无序不重复元素集
 |  
 |  Methods defined here:
 |  
 |  __and__(self, value, /)
 |      Return self&value.
 |  
 |  __contains__(...)
 |      x.__contains__(y) <==> y in x.
 |  
 |  __eq__(self, value, /)
 |      Return self==value.
 |  
 |  __ge__(self, value, /)
 |      Return self>=value.
 |  
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
 |  
 |  __gt__(self, value, /)
 |      Return self>value.
 |  
 |  __iand__(self, value, /)
 |      Return self&=value.
 |  
 |  __init__(self, /, *args, **kwargs)
 |      Initialize self.  See help(type(self)) for accurate signature.
 |  
 |  __ior__(self, value, /)
 |      Return self|=value.
 |  
 |  __isub__(self, value, /)
 |      Return self-=value.
 |  
 |  __iter__(self, /)
 |      Implement iter(self).
 |  
 |  __ixor__(self, value, /)
 |      Return self^=value.
 |  
 |  __le__(self, value, /)
 |      Return self<=value.
 |  
 |  __len__(self, /)
 |      Return len(self).
 |  
 |  __lt__(self, value, /)
 |      Return self<value.
 |  
 |  __ne__(self, value, /)
 |      Return self!=value.
 |  
 |  __or__(self, value, /)
 |      Return self|value.
 |  
 |  __rand__(self, value, /)
 |      Return value&self.
 |  
 |  __reduce__(...)
 |      Return state information for pickling.
 |  
 |  __repr__(self, /)
 |      Return repr(self).
 |  
 |  __ror__(self, value, /)
 |      Return value|self.
 |  
 |  __rsub__(self, value, /)
 |      Return value-self.
 |  
 |  __rxor__(self, value, /)
 |      Return value^self.
 |  
 |  __sizeof__(...)
 |      S.__sizeof__() -> size of S in memory, in bytes
 |  
 |  __sub__(self, value, /)
 |      Return self-value.
 |  
 |  __xor__(self, value, /)
 |      Return self^value.
 |  
 |  add(...)
 |      Add an element to a set.
 |      往集合添加一个元素
 |      This has no effect if the element is already present.
 |      如果元素已经存在则集合不会有变化
 |  
 |  clear(...)
 |      Remove all elements from this set.
 |      删除集合中所有元素
 |  
 |  copy(...)
 |      Return a shallow copy of a set.
 |      返回集合的浅拷贝
 |  
 |  difference(...)
 |      Return the difference of two or more sets as a new set.
 |      (i.e. all elements that are in this set but not the others.)
 |      返回b在a中的相对补集,即a-b={x|x∈a且x∉b}
 |      a.difference(b)表示返回a中有但b中没有的元素集。返回的是新集合对象。
 |  
 |  difference_update(...)
 |      Remove all elements of another set from this set.
 |      与上一个函数的区别是,返回的是经过处理的本对象(a)。
 |
 |  discard(...)
 |      Remove an element from a set if it is a member.
 |      从集合中删除参数中指定的元素。
 |      If the element is not a member, do nothing.
 |      若参数对应的元素不存在,则原集合不做操作
 |  
 |  intersection(...)
 |      Return the intersection of two sets as a new set.
 |      a.intersection(b).返回两个集合的交集,返回的是新集合
 |      (i.e. all elements that are in both sets.)
 |  
 |  intersection_update(...)
 |      Update a set with the intersection of itself and another.
 |      与上一个函数的区别是,运算得到的交集放在a中
 |
 |  isdisjoint(...)
 |      Return True if two sets have a null intersection.
 |      如果两个集合交集为空,则返回True,否则返回False
 |
 |  issubset(...)
 |      Report whether another set contains this set.
 |      若本集合是参数的子集,则返回True,否则返回False
 |  
 |  issuperset(...)
 |      Report whether this set contains another set.
 |      若本集合包含参数集合(即参数是子集),则返回True,否则返回False
 |  
 |  pop(...)
 |      Remove and return an arbitrary set element.
 |      Raises KeyError if the set is empty.
 |      删除并返回集合中的第一个元素,若集合是空集则抛KeyError异常
 |      注意:这个第一个元素与加入集合的先后顺序无关,可能与元素的hash值对应的存储位置有关。
 |
 |  remove(...)
 |      Remove an element from a set; it must be a member.
 |      从集合中删除指定元素
 |      If the element is not a member, raise a KeyError.
 |      若元素不存在则抛KeyError异常
 |  
 |  symmetric_difference(...)
 |      Return the symmetric difference of two sets as a new set
 |      a.symmetric_difference(b)。表示返回a∪b-a∩b。即将a、b的并集中a、b都有的元素删除,返回新集合。
 |      (i.e. all elements that are in exactly one of the sets.)
 |  
 |  symmetric_difference_update(...)
 |      Update a set with the symmetric difference of itself and another.
 |      与上一个函数的区别是,运算得到的集合放入a中,即a发生了变化
 |  
 |  union(...)
 |      Return the union of sets as a new set.
 |      a.union(b),返回两个集合的并集,返回的是新集合
 |      (i.e. all elements that are in either set.)
 |  
 |  update(...)
 |      Update a set with the union of itself and others.
 |      与上一个函数的区别是,生成的并集放在a中
 |  ----------------------------------------------------------------------
 |  Static methods defined here:
 |  
 |  __new__(*args, **kwargs) from builtins.type
 |      Create and return a new object.  See help(type) for accurate signature.
 |  
 |  ----------------------------------------------------------------------
 |  Data and other attributes defined here:
 |  
 |  __hash__ = None
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!