Python中max()函数的用法-创新互联
小编给大家分享一下Python中max() 函数的用法,希望大家阅读完这篇文章后大所收获,下面让我们一起去探讨吧!

示例演示:
Python max() function
max() 该功能用于–
计算在其参数中传递的较大值。
如果字符串作为参数传递,则在字典上的较大值。
Find largest integer in array
>>> nums = [1, 8, 2, 23, 7, -4, 18, 23, 42, 37, 2] >>> max( nums ) 42 #Max value in array
Find largest string in array
>>> blogName = ["how","to","do","in","java"] >>> max( blogName ) 'to' #Largest value in array
Find max key or value
有点复杂的结构。
>>> prices = {
'how': 45.23,
'to': 612.78,
'do': 205.55,
'in': 37.20,
'java': 10.75
}
>>> max( prices.values() )
612.78
>>> max( prices.keys() ) #or max( prices ). Default is keys().
'to'看完了这篇文章,相信你对Python中max() 函数的用法有了一定的了解,想了解更多相关知识,欢迎关注创新互联行业资讯频道,感谢各位的阅读!
网页名称:Python中max()函数的用法-创新互联
网站路径:http://www.jxjierui.cn/article/doeidg.html


咨询
建站咨询
