新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
創(chuàng)新互聯(lián)Python教程:Pythonmax()函數(shù)怎么用?什么原理?
與max函數(shù)經(jīng)常一起出現(xiàn)的是min函數(shù),對于這兩個函數(shù),因為長得差不多,使得經(jīng)常唄搞混,要如何弄清這兩個函數(shù)呢?一起來看下把~

示例演示:
Python max() function
max() 該功能用于–
計算在其參數(shù)中傳遞的值。
如果字符串作為參數(shù)傳遞,則在字典上的值。
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'
好了,以上就是關于max函數(shù)的使用了,如需了解更多python實用知識,點擊進入PyThon學習網(wǎng)教學中心。
文章題目:創(chuàng)新互聯(lián)Python教程:Pythonmax()函數(shù)怎么用?什么原理?
網(wǎng)站網(wǎng)址:http://fisionsoft.com.cn/article/coshcdi.html


咨詢
建站咨詢
