x = [1, 2, 3]
0 开始)访问元素:e = x[1] # e == 2
+ 运算符来串联两个列表。示例:x = [1, 2] + [3, 4] # x == [1, 2, 3, 4] x = ["a", "b"] x += ["c"] # x == ["a", "b", "c"]
['a', 'b', 'c', 'd'][1:3] # ['b', 'c'] ['a', 'b', 'c', 'd'][::2] # ['a', 'c'] ['a', 'b', 'c', 'd'][3:0:-1] # ['d', 'c', 'b']
成员
append
None list.append(item)参数
| 参数 | 说明 | 
|---|---|
| item | 必需参数 要添加到末尾的项。 | 
清除
None list.clear()扩展
None list.extend(items)参数
| 参数 | 说明 | 
|---|---|
| items | 必需参数 要添加到末尾的项。 | 
索引
int list.index(x, start=None, end=None)
参数
| 参数 | 说明 | 
|---|---|
| x | 必需 要搜索的对象。 | 
| start | int;或 None;
                                     默认值为None要检查的列表部分的起始索引。 | 
| end | int;或 None;
                                     默认值为None要检查的列表部分的结束索引。 | 
insert
None list.insert(index, item)参数
| 参数 | 说明 | 
|---|---|
| index | 必需 指定位置的索引。 | 
| item | 必需 相应商品。 | 
pop
unknown list.pop(i=-1)
index,则移除并返回列表中的最后一项。
          
      参数
| 参数 | 说明 | 
|---|---|
| i | int;或 None;
                                     默认值为-1商品的索引。 | 
移除
None list.remove(x)参数
| 参数 | 说明 | 
|---|---|
| x | 必需 要移除的对象。 |