Python 3 教程 Python3 List max()方法

augustine · 2022-03-13 22:57:11 · 热度: 15

描述

max() 方法返回列表元素中的最大值。

语法

max()方法语法:

max(list)

参数

  • list -- 要返回最大值的列表。

返回值

返回列表元素中的最大值。

实例

以下实例展示了 max()函数的使用方法:

实例

#!/usr/bin/python3

list1, list2 = ['Google', 'Codercto', 'Taobao'], [456, 700, 200]

print ("list1 最大元素值 : ", max(list1))
print ("list2 最大元素值 : ", max(list2))

以上实例输出结果如下:

list1 最大元素值 :  Taobao
list2 最大元素值 :  700

查看更多 Python 列表函数&方法

猜你喜欢:
暂无回复。
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册