一. list列表扩展的方式有几种(或者说添加元素的方法)
1:append 将对象追加到列表中最后一个元素的末尾。
2:extend 通过从可选对象追加元素来扩展列表。
3:insert 在索引前插入对象,以此来扩展列表。
二. 对["cherry", "litchi", "strawberry", "mangosteen", "pomelo", "pineapple", "pitaya", "durian"]进行默认排序![](https://img-blog.csdnimg.cn/3796744422e440d889e39e86e4143d54.png)
对上面的列表使用第三个字母进行排序![](https://img-blog.csdnimg.cn/9bc00b071b6a4128ba0d610de377d350.png)
三. dict中所有方法的使用(先写源代码再写样例)
1:clear
clear(...) | D.clear() -> None. Remove all ![](https://img-blog.csdnimg.cn/e132606236124d578fa4a16f3d80344e.png)
2:copy
copy(...) | D.copy() -> a shallow copy of D![](https://img-blog.csdnimg.cn/b54a896146f645e99f79c3d2be97115d.png)
3:get
get(self, key, default=None, /) ![](https://img-blog.csdnimg.cn/1e121cb1d4b14427862b98565f9736b5.png)
4:items
items() -> a set-like object providing a view on D's items![](https://img-blog.csdnimg.cn/043dbed709ae4f6cb2498c7dbd61f1da.png)
5:keys
keys(...) | D.keys() -> a set-like object providing a view on D's keys![](https://img-blog.csdnimg.cn/12c42a568c984af88d327aae29af0654.png)
6:pop
pop(...) | D.pop(k[,d]) -> v, remove specified key and return the corresponding value. ![](https://img-blog.csdnimg.cn/13b215b10b2246d0b0ba115566da1f59.png)
7:popitem
popitem(self, /) | Remove and return a (key, value) pair as a 2-tuple.((key, value)) ![](https://img-blog.csdnimg.cn/4b94f6e404fb401a9682aed95de2d26a.png)
8:setdefault
setdefault(self, key, default=None, /) | Insert key with a value of default if key is not in the dictionary. ![](https://img-blog.csdnimg.cn/bbe30c1b549241df8be876fdc07d2048.png)
9:update
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] ![](https://img-blog.csdnimg.cn/4f89766ab1374eeda4f49bf75c84dfdf.png)
10:value
values(...) | D.values() -> an object providing a view on D's ![](https://img-blog.csdnimg.cn/1c73544ed3b148a0b9d5e86a525fcb12.png)