1. list列表扩展的方式有几种(或者说添加元素的方法)
(1)append(self, object, /) 追加
(2) extend(self, iterable, /) 扩展
(3)insert(self, index, object, /) 插入
2. 对["cherry", "litchi", "strawberry", "mangosteen", "pomelo", "pineapple", "pitaya", "durian"]进行默认排序
、
对上面的列表使用第三个字母进行排序
3. dict中所有方法的使用(先写源代码再写样例)
clear(...) 清空
| D.clear() -> None. Remove all items from D.
|
| copy(...)
| D.copy() -> a shallow copy of D
|
| get(self, key, default=None, /)
| Return the value for key if key is in the dictionary, else default.
|
| 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
|
| pop(...)
| D.pop(k[,d]) -> v, remove specified key and return the corresponding value.移除指定的键并返回相应的值。
|
| If key is not found, default is returned if given, otherwise KeyError is raised
|
| popitem(self, /)返回并删除字典中的最后一对键和值
| Remove and return a (key, value) pair as a 2-tuple.
|
| Pairs are returned in LIFO (last-in, first-out) order.
| Raises KeyError if the dict is empty.
|
| setdefault(self, key, default=None, /)
| Insert key with a value of default if key is not in the dictionary.
| 如果键不在字典中,则插入值为默认值的键。
| Return the value for key if key is in the dictionary, else default.
| 如果 key 在字典中,返回 key 的值,否则默认值。