av激情亚洲男人的天堂国语,日韩欧美精品一中文字幕,无码av一区二区三区无码,国产又色又爽又刺激的a片,国产又色又爽又刺激的a片

創(chuàng)新互聯(lián)Python教程:Python min()

內置函數(shù)min()有助于返回給定 iterable 中的最小元素。也可以在兩個或多個參數(shù)之間找到最小的元素。

創(chuàng)新互聯(lián)-專業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設、高性價比旬陽網(wǎng)站開發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫,直接使用。一站式旬陽網(wǎng)站制作公司更省心,省錢,快速模板網(wǎng)站建設找我們,業(yè)務覆蓋旬陽地區(qū)。費用合理售后完善,十余年實體公司更值得信賴。

 # to find the smallest item in an iterable
**min(iterable, *iterables, key, default)** 
 # to find the smallest item between two or more objects
**min(arg1, arg2, *args, key)** 

最小()參數(shù):

帶有 iterable 的min()函數(shù)具有以下參數(shù)。

*分鐘(可重復,可重復,鍵,默認)**

參數(shù)描述必需/可選
可迭代的諸如列表、元組、集合、字典等可條目。需要
*可重復任意數(shù)量的可滴定物;可以不止一個可選擇的
傳遞數(shù)據(jù)項并進行比較的一種關鍵功能可選擇的
系統(tǒng)默認值如果給定的 iterable 為空,則為默認值可選擇的

不帶iterable()iterable()函數(shù)有以下參數(shù)。

【t0 min(arg1、arg2、*args、鍵)】的縮寫

參數(shù)描述必需/可選
arg1一個對象;可以是數(shù)字、字符串等需要
arg2一個對象;可以是數(shù)字、字符串等需要
*參數(shù)任意數(shù)量的對象可選擇的
傳遞每個參數(shù)并進行比較的一個關鍵函數(shù)可選擇的

最小()返回值

在傳遞空迭代器的情況下,它會引發(fā) ValueError 異常。為了避免這種情況,我們可以傳遞默認參數(shù)。 如果我們傳遞多個迭代器,那么從給定的迭代器中返回最小的項。

| 投入 | 返回值 | | 整數(shù) | 最小整數(shù) | | 線 | 具有最小 Unicode 值的字符 |

Python 中min()方法的示例

示例 1:獲取列表中最小的項目

 number = [13, 2, 8, 25, 10, 46]
smallest_number = min(number);

print("The smallest number is:", smallest_number)
Output 

輸出:

The smallest number is: 2

示例 2:列表中最小的字符串

 languages = ["Python", "C Programming", "Java", "JavaScript"]
smallest_string = min(languages);

print("The smallest string is:", smallest_string) 

輸出:

The smallest string is: C Programming

示例 3:在字典中查找min()

 square = {2: 4, 3: 9, -1: 1, -2: 4}

# the smallest key
key1 = min(square)
print("The smallest key:", key1)    # -2

# the key whose value is the smallest
key2 = min(square, key = lambda k: square[k])

print("The key with the smallest value:", key2)    # -1

# getting the smallest value
print("The smallest value:", square[key2])    # 1 

輸出:

TThe smallest key: -2
The key with the smallest value: -1
The smallest value: 1

例 4:在給定的數(shù)字中找出最小值

 result = min(4, -5, 23, 5)
print("The minimum number is:", result) 

輸出:

The minimum number is -5

示例 5:查找對象的最小值()

 class Data:
    id = 0

    def __init__(self, i):
        self.id = i

    def __str__(self):
        return 'Data[%s]' % self.id

def get_data_id(data):
    return data.id

# min() with objects and key argument
list_objects = [Data(1), Data(2), Data(-10)]

print(min(list_objects, key=get_data_id)) 

輸出:

Data[-10]

網(wǎng)頁標題:創(chuàng)新互聯(lián)Python教程:Python min()
鏈接地址:http://uogjgqi.cn/article/djdiiop.html
掃二維碼與項目經(jīng)理溝通

我們在微信上24小時期待你的聲音

解答本文疑問/技術咨詢/運營咨詢/技術建議/互聯(lián)網(wǎng)交流