Python初见 List,Tuple,Dict,Set的增删改查
来源:互联网 发布:云计算和大数据年收入 编辑:程序博客网 时间:2024/06/06 00:08
有序集合
List,列表,有序
Tuple,元组,有序无序集合
Dict,字典,key-value(键值对)
Set,类似字典中Key的集合
List
定义
a = ["aa", "bb", "cc"]
增
1.尾部增加
a.append("dd")
2.特定位置增加
a.insert(1, "a0")
删
1.末尾删
a.pop()
2.特定位置删
a.pop(0)#第一个
3.删除重复第一个值
a.remove("cc")
改
a[2]=""#改第三个
查
b=a.index("bb", )
元组
定义
a=(1,2,3)
查
1.查询值出现的次数
G=(1,2,3)a=G.count(1)
2.查询值出现的位置
b=G.index(1, )
字典dict
定义
d = { "name":"mm", "age":"17"}
增
d["heheh"]="sss"
删
d.pop("name")
改
d["name"]="heh"
查
print d.get("name")d.has_key("name")
set
定义
p=set([1,2,3,4])
增
p.add(5)
删
1.删除第一个
p.pop()
2.删除一个值
p.remove(3)
3.并集
p.update([1,6,7])#并集e=set([1,2])r=set([2,3,4])y=e|r
4.交集
t=e&r
0 0
- Python初见 List,Tuple,Dict,Set的增删改查
- Python - list, tuple, dict, set的区别
- Python的list、tuple、dict、set
- python list tuple dict set
- Python--list,tuple,dict,set.
- python的dict,set,list,tuple简单分析
- Python中set、list、dict、tuple的比较
- python 里list, tuple, set, dict的异同
- python的dict,set,list,tuple简单分析 老搞混
- python的dict,set,list,tuple应用详解
- python的List,Tuple,Dict,Set简略学习。
- python中list,tuple,dict,set的区别及联系
- Python中list,tuple,dict,set的区别和用法
- Python中list,tuple,dict,set的区别和用法
- python中list/tuple/dict/set的区别
- Python中list,tuple,dict,set的区别和用法
- Python set list dict tuple 区别
- Python List+Tuple+Dict+Set小结
- JavaScript学习笔记——引用类型:Array类型
- python编程书推荐9本免费的
- [Feyat Cup 1.0][JZOJ3338]法法塔的奖励
- 求链表结点的阶乘和
- 小备注
- Python初见 List,Tuple,Dict,Set的增删改查
- c语言中!&&||的逻辑小结
- url-pattern值格式
- 计算机网络体系结构—数据传递流
- Linux 4.33 字符设备驱动分析
- Windows 7(64位)搭建Python开发环境
- Android消息机制之Handler
- Node.js调试工具之node-inspector
- MFC Tap激活窗口