class dict(object): """ dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k]
一.字符串类型(str) class str(basestring): """ str(object='') -> string Return a nice string representation of the object. If the argument is a string, the return value is the same object. """ def capitalize(self): ""&q
使用dict,zip方法将两个list合并为dict keys = ["b", "a", "c", "e", "d"] values = ["] dict(zip(keys, values)) #该dict是无序的 d=dict(zip(keys, values)) [(k,d[k]) for k in sorted(d.keys())] #按keys排序,升序 [(k,d[k]) for k i
字典是列表中常用的方法,我们经常处理字典,字典嵌套,很多复杂的操作都来自于基础,只是改变了样式而已,本质是不变的.下面来看看字典中常用的功能都有那些: 1.clear(self) def clear(self): # real signature unknown; restored from __doc__ """ D.clear() -> None. Remove all items from D. """ pass clear(