@[TOC](list 列表常用操作汇总)
1、list定义
1 | list = ['a', 'b', '123', 'z', '456'] |
2、list负数索引
1 | list = ['a', 'b', '123', 'z', '456'] |
3、list切片
1 | list = ['a', 'b', '123', 'z', '456'] |
4、list增加元素
1 | list = ['a', 'b', '123', 'z', '456'] |
5、list删除元素
1 | list = ['a', 'b', 'new', '123', 'z', '456', 'new', 'new3', 'new4'] |
6、list搜索
1 | list = ['a', 'b', 'new', '123', 'z', '456', 'new', 'new3', 'new4'] |
7、list运算符
1 | list = ['a', 'b', '123', 'z', '456'] |
8、使用join链接list成为字符串
1 | params = {'server':'abc', 'database':'master', 'uid':'123', 'pwd':'456'} |
9、list分割字符串
1 | list = ['server=abc', 'database=master', 'uid=123', 'pwd=456'] |
10、list的映射
1 | list = [1, 5, 3, 10] |
11、dict(字典)中的解析(返回的为list形式)
1 | params = {'server':'abc', 'database':'master', 'uid':'123', 'pwd':'456'} |
12、list过滤
1 | list = ['a', 'b', '123', 'z', '456', 'b', 'd', 'd'] |