2019-05-21

------------------------

help(tuple)

-------------------------

Help on class tuple in module builtins:

class tuple(object)
|  tuple(iterable=(), /)

|  Built-in immutable sequence.

|  If no argument is given, the constructor returns an empty tuple.
|  If iterable is specified the tuple is initialized from iterable's items.

|  If the argument is a tuple, the return value is the same object.

|  Methods defined here:

|  __add__(self, value, /)
|      Return self+value.

|  __contains__(self, key, /)
|      Return key in self.

|  __eq__(self, value, /)
|      Return self==value.

|  __ge__(self, value, /)
|      Return self>=value.

|  __getattribute__(self, name, /)
|      Return getattr(self, name).

|  __getitem__(self, key, /)
|      Return self[key].

|  __getnewargs__(self, /)

|  __gt__(self, value, /)
|      Return self>value.

|  __hash__(self, /)
|      Return hash(self).

|  __iter__(self, /)
|      Implement iter(self).

|  __le__(self, value, /)
|      Return self<=value.

|  __len__(self, /)
|      Return len(self).

|  __lt__(self, value, /)
|      Return self<value.

|  __mul__(self, value, /)
|      Return self*value.

|  __ne__(self, value, /)
|      Return self!=value.

|  __repr__(self, /)
|      Return repr(self).

|  __rmul__(self, value, /)
|      Return value*self.

|  count(self, value, /)
|      Return number of occurrences of value.

|  index(self, value, start=0, stop=9223372036854775807, /)
|      Return first index of value.
|     
|      Raises ValueError if the value is not present.

|  ----------------------------------------------------------------------
|  Static methods defined here:

|  __new__(*args, **kwargs) from builtins.type
|      Create and return a new object.  See help(type) for accurate signature.
---------------------------------------------------

# count() 计算某个元素在元组中出现的次数
tuple1 = (3,2,4,1,3,6)
print(tuple1.count(3))

-----------------------------------------------------

# index() 获取值在元组中的索引
tuple1 = (3,2,4,1,3,6)
print(tuple1.index(3))
print(tuple1.index(3,1,5))

---------------------------------------------------------

# clear() 清除整个字典   返回None
dict1 = {'a':1, 'b':2, 'c':3}
dict2 = dict1.copy()
print(dict2)

--------------------------------------------------------

# fromkeys() 按照指定的序列为键创建字典,值都是一样的
list1 = ['a', 'b', 'c']
dict1 = {}.fromkeys(list1)
dict2 = {}.fromkeys(list1, 3)
print(dict1,dict2)

---------------------------------------------------------

# get() 根据键获取指定的值    找不到的键如果没有默认值则返回默认值, 如果没默认值,则返回None
dict1 = {'a':1, 'b':2, 'c':3}
print(dict1.get('b'))
print(dict1.get('d'))
print(dict1.get('d', 4))

--------------------------------------

# items() 将字典变成类似于元组的形式方便遍历
dict1 = {'a':1, 'b':2, 'c':3}
for k,v in dict1.items():
    print(k,v)
for i in dict1.items():
    print(i)
   
print(dict1.items())

----------------------------------

# pop() 移除字典中指定元素  返回键所对应的值,如果键不存在,则返回默认值,如果键找不到,没有默认值,就会报错
dict1 = {'a':1, 'b':2, 'c':3}
print(dict1.pop('a'))
print(dict1)
print(dict1.pop('d', 4))
print(dict1.pop('d'))

----------------------------------

# popitem() 移除字典的键值时,返回移除的键和值
dict1 = {'d':4,'a':1, 'b':2, 'c':3 }
print(dict1.popitem())

------------------------------------

# update() 修改字典中的值
dict1 = {'d':4, 'a':1, 'b':2, 'c':3}
dict1.update({'a':3, 'b':4, 'e':6})
print(dict1)

------------------------------------

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.)

|  difference_update(...)
|      Remove all elements of another set from this set.

|  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.
|     
|      (i.e. all elements that are in both sets.)

|  intersection_update(...)
|      Update a set with the intersection of itself and another.

|  isdisjoint(...)
|      Return True if two sets have a null intersection.

|  issubset(...)
|      Report whether another set contains this set.

|  issuperset(...)
|      Report whether this set contains another set.

|  pop(...)
|      Remove and return an arbitrary set element.
|      Raises KeyError if the set is empty.

|  remove(...)
|      Remove an element from a set; it must be a member.
|     
|      If the element is not a member, raise a KeyError.

|  symmetric_difference(...)
|      Return the symmetric difference of two sets as a new set.
|     
|      (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.

|  union(...)
|      Return the union of sets as a new set.
|     
|      (i.e. all elements that are in either set.)

|  update(...)
|      Update a set with the union of itself and others.

|  ----------------------------------------------------------------------
|  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

----------------------------------------

a = set()
print(a)
list1 = [1,2,3,4]
a = set(list1)
print(a)

--------------------------------------------

# add() 向集合中添加元素
set1 = {5,1,2,3,4,'b','u'}
set1.add(6)
print(set1)

--------------------------------

# clear()   清空集合
# copy()   复制集合
# pop()    随机弹出一个元素
a = {'a', 'b', 'f', 4}
a.pop()
print(a)

-----------------------------------

# remove 删除集合中的某个值,如果这个值不在集合中会报错
a = {'a', 'b', 'f', 4}
a.remove(4)
print(a)
a.remove(4)

-------------------------------------

# difference() 差集
# difference_update() 区别就是第一个返回一个新的集合,第二个把原来集合覆盖
set1 = {1,2,3,4,7}
set2 = {2,4,8,111,24}
set3 = set1.difference(set2)
print(set3)
print(set1)

------------------------------------------

最新文章

  1. Tomcat7配置及其servlet调用详解
  2. JavaScript内的类型转换
  3. linux第8天 connect强化
  4. [iOS 开发] Xcode常见报错及解决办法
  5. inux 安装中文支持包及中文字符集配置 +i18n
  6. easyui的datagrid删除一条记录后更新出问题
  7. [Script]EBS里查看模块的版本、文件的版本信息【Z】
  8. 定向爬虫之爬一爬各个学校新闻的认识(【1】对Url的认识)
  9. FineUIMvc随笔(6)对比WebForms和MVC中表格的数据库分页
  10. 虚拟机访问互联网的方法 -- 以RedHat系为例
  11. 聊聊Spring Cloud版本的那些事儿
  12. Navicat Premium for Mac完美破解
  13. Matplotlib-画图种类
  14. 基于VS Code创建Spring Boot项目开发REST API(一)
  15. 首页背景图片在PC端有显示,在手机端不显示的解决方法
  16. 读取文件时,使用file.eof()判断结尾注意事项
  17. Spring BeanUtils简单使用
  18. Oracle 学习总结 - 表和索引的性能优化
  19. php sqlserver及xdebug扩展配置
  20. 3.fIddler的使用

热门文章

  1. Linux内核调试方法总结之内核通知链
  2. 【洛谷P5018 对称二叉树】
  3. Vue实现音乐播放器(六):jsonp的应用+抓取轮播图数据
  4. 2019 Nanchang Onsite
  5. Maven install报错:MojoFailureException ,To see the full stack trace of the errors, re-run Maven with the -e switch.解决
  6. FineTuning机制的分析
  7. IDE(Pycharm&amp;&amp;IDEA)配置文件模版
  8. failed to open stream: HTTP request failed! HTTP/1.1 505 HTTP Version Not Supported
  9. 老技术记录-C#+SqlServer使用SqlDependency监听数据库表变化
  10. PCB电路设计 altiumdesigner(项目软件总结)