一、list添加元素的方法:
1、append(在末尾添加对象)
2、extend(追加元素列表)
3、insert(在索引之前添加对象)
二、对["cherry", "litchi", "strawberry", "mangosteen", "pomelo", "pineapple", "pitaya", "durian"]进行默认排序
三、dict中所有方法的使用(先写源代码再写样例)
clear(...)删除所有元素
D.clear() -> None
从 D 中删除所有项目
copy(...) 拷贝
D.copy() -> a shallow copy of D
D.copy() -> D 的浅层副本
fromkeys(*args, **kwargs)
Create a new dictionary with keys from iterable and values set to value
items(...)
D.items() -> a set-like object providing a view on D's items
-keys(...)
D.keys() -> a set-like object providing a view on D's keys
get(self, key, default=None, /)|
|Return the value for key if key is in the dictionary, else default. |
pop(...)
D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
popitem(self, /)(随机删除key值)
Remove and return a (key, value) pair as a 2-tuple.
删除(键、值)对并将其作为 2 元组返回
Pairs are returned in LIFO (last-in, first-out) order.
Raises KeyError if the dict is empty.
成对按后进先出(后进先出)顺序返回。
如果字典为空,则引发 KeyError。
如果字典为空,则引发 KeyError
setdefault(self, key, default=None, /)
Insert key with a value of default if key is not in the dictionary.
如果键不在字典中,则插入值为默认值的键
setdefault(self, key, default=None, /)
Insert key with a value of default if key is not in the dictionary.
如果键不在字典中,则插入值为默认值的键
在执行 update方法时,如果被更新的字典中己包含对应的键值对,那么原 value 会被覆盖;如果被更新的字典中不包含对应的键值对,则该键值对被添加进去。



