Python字典常见函数
2018-02-21 13:27
218 查看
items()
keys()
values()
get()
pop()
popitem()
update()
setdefault()
D.items() -> a set-like object providing a view on D’s items
D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None.
D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
If key is not found, d is returned if given, otherwise KeyError is raised
D.popitem() -> (k, v), remove and return some (key, value) pair as a
2-tuple; but raise KeyError if D is empty.
D.update([E, ]**F) -> None. Update D from dict/iterable E and F.
If E is present and has a .keys() method, then does: for k in E: D[k] = E[k]
If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v
In either case, this is followed by: for k in F: D[k] = F[k]
D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D
参考Python基础(一)
keys()
values()
get()
pop()
popitem()
update()
setdefault()
D.items() -> a set-like object providing a view on D’s items
D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None.
D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
If key is not found, d is returned if given, otherwise KeyError is raised
D.popitem() -> (k, v), remove and return some (key, value) pair as a
2-tuple; but raise KeyError if D is empty.
D.update([E, ]**F) -> None. Update D from dict/iterable E and F.
If E is present and has a .keys() method, then does: for k in E: D[k] = E[k]
If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v
In either case, this is followed by: for k in F: D[k] = F[k]
D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D
参考Python基础(一)
相关文章推荐
- Python常见字典内建函数用法示例
- Python常见文件操作的函数示例
- 初学Python的学习笔记2----dist字典,set集合,声明函数,函数参数
- python 字典的函数
- Python实现自定义函数的5种常见形式分析
- python 函数参数的传递(参数带星号的说明) 元组传递 字典传递
- Python中如何避免使用多个分支语句(多个if和else)——函数字典(Function Map)简介
- python 中常用不常见的一些函数
- Po学校Python第四课(循环+文件操作+字典+函数)
- Python sorted 函数,对字典按值进行排序
- [置顶] Python联系笔记2[列表,元组,集合,字典,函数,文件操作,模块,类]
- 常见内部函数----Python
- python 字典入库(mysql)函数
- python函数max与min的高阶使用,list强转的本质,字典列表比值办法max的隐藏功能
- Python中常见的文件对象内建函数
- Python常见文件操作的函数示例
- Python常见文件操作的函数示例
- Python字典常见操作1
- python三之缺省函数(及字典)
- Python学习入门基础教程(learning Python)--8.3 字典常用的方法函数介绍