1. sorted()
对可迭代对象进行排序
sorted(iterable, cmp=None, key=None, reverse=False) --> new sorted list
- 示例
>>> a = [12, 98, 23, 34, 17]
>>> sorted(a)
[12, 17, 23, 34, 98]
2. max()
获取可迭代对象或者多个参数的最大值
max(iterable[, key=func]) -> value
max(a, b, c, ...[, key=func]) -> valueWith a single iterable argument, return its largest item.
With two or more arguments, return the largest argument.
- 示例
>>> a = [12, 98, 23, 34, 17]
>>> max(a)
98
3. min()
获取可迭代对象或者多个参数的最小值
min(iterable[, key=func]) -> value
min(a, b, c, ...[, key=func]) -> valueWith a single iterable argument, return its smallest item.
With two or more arguments, return the smallest argument.
- 示例
>>> a = [12, 98, 23, 34, 17]
>>> min(a)
12
4. len()
获取一个序列或者集合的长度
len(object) -> integerReturn the number of items of a sequence or collection.
- 示例
>>> a = [12, 98, 23, 34, 17]
>>> len(a)
5
5. index()
获取列表中值所对应的索引值
L.index(value, [start, [stop]]) -> integer -- return first index of value.
Laises ValueError if the value is not present.
- 示例
>>> a = [12, 98, 23, 34, 17]
>>> a.index(98)
1
网友评论