首先,我們來看下map()內(nèi)置函數(shù)的用法:
創(chuàng)新互聯(lián)公司主要從事做網(wǎng)站、成都網(wǎng)站設(shè)計、網(wǎng)頁設(shè)計、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)博興,十多年網(wǎng)站建設(shè)經(jīng)驗,價格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):18980820575
>>> help(map)
Help on class map in module builtins:class map(object)
? |? map(func, *iterables) --> map object
? |?
? |? Make an iterator that computes the function using arguments from
? |? each of the iterables.? Stops when the shortest iterable is exhausted.
? |?
? |? Methods defined here:
? |?
? |? __getattribute__(self, name, /)
? |????? Return getattr(self, name).
? |?
? |? __iter__(self, /)
? |????? Implement iter(self).
? |?
? |? __next__(self, /)
? |????? Implement next(self).
? |?
? |? __reduce__(...)
? |????? Return state information for pickling.
? |?
? |? ----------------------------------------------------------------------
? |? Static methods defined here:
? |?
? |? __new__(*args, **kwargs) from builtins.type
? |????? Create and return a new object.? See help(type) for accurate signature.map()內(nèi)置函數(shù)有兩個參數(shù),第一個參數(shù)為函數(shù),第二個參數(shù)為可迭代對象,將可迭代對象中的每個元素作為函數(shù)的
參數(shù)進行運算,可以看到,第二個參數(shù)亦是一個收集參數(shù),所以當?shù)诙€元素為收集參數(shù)時,其支持多個可迭代對象,
可迭代對象會依次取一個元素組成一個元組,然后傳遞給函數(shù)進行運算,當可迭代對象長度不一致時,到最短的那個
終止
例:
>>> list(map(lambda x:x**2,range(10)))
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]>>> list(map(lambda x,y:x+y,[1,8,10],[8,6,3,7,5,4]))
[9, 14, 13]
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機、免備案服務(wù)器”等云主機租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應用場景需求。
網(wǎng)站題目:map()內(nèi)置函數(shù)-創(chuàng)新互聯(lián)
網(wǎng)頁路徑:http://chinadenli.net/article16/pdogg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供服務(wù)器托管、面包屑導航、關(guān)鍵詞優(yōu)化、網(wǎng)站設(shè)計公司、微信小程序、網(wǎng)站排名
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容