1.添加一个元素: add(...) Addan element to a set. 1 2 3 4 >>> a = {'shaw',11,22} >>>a.add('sina') >>> a {'sina', 11, 22,'shaw'} 2.清空集合 clear(...) Remove all elements from this set. 1 2 3 4 >>> a = {'shaw',11,22} >>>…
Python认为一切皆为对象:比如我们初始化一个list时: li = list('abc') 实际上是实例化了内置模块builtins(python2中为__builtin__模块)中的list类: class list(object): def __init__(self, seq=()): # known special case of list.__init__ """ list() -> new empty list list(iterable) ->…
python学习笔记整理 数据结构--字典 无序的 {键:值} 对集合 用于查询的方法 len(d) Return the number of items in the dictionary d. 返回元素个数 d[key] Return the item of d with key key. Raises a KeyError if key is not in the map. If a subclass of dict defines a method _missing_() and key…