日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
創(chuàng)新互聯(lián)Python教程:Pythondiscard()

python 中的discard()函數(shù)有助于在元素存在的情況下從集合中移除或丟棄指定的元素。

 **s.discard(element)** #where element may be a integer,string etc. 

丟棄()參數(shù):

discard()函數(shù)接受一個(gè)參數(shù)。此方法類似于remove()方法,不同之處在于,如果給定元素不在集合中,discard()方法會(huì)引發(fā)錯(cuò)誤,但remove()不會(huì)。

參數(shù) 描述 必需/可選
元素要搜索和移除的項(xiàng)目需要

丟棄()返回值

discard()方法不返回任何內(nèi)容。它只是通過(guò)從集合中移除指定的元素來(lái)更新集合。

Python 中discard()方法的示例

示例discard()在 Python 中是如何工作的?

 alphabets = {'a', 'b', 'c', 'd'}

alphabets .discard(c)
print('Alphabets = ', alphabets )

numbers.discard(e)
print('Alphabets = ', alphabets ) 

輸出:

 Alphabets =  {'a', 'b', 'd'}
Alphabets =  {'a', 'b', 'd'} 

示例 Python 中丟棄()的工作方式

 alphabets = {'a', 'b', 'c', 'd'}
#Returns none
print(alphabets .discard(c))
print('Alphabets = ', alphabets ) 

輸出:

 None
Alphabets = {'a', 'b', 'd'} 

當(dāng)前題目:創(chuàng)新互聯(lián)Python教程:Pythondiscard()
轉(zhuǎn)載來(lái)源:http://m.5511xx.com/article/cdhoded.html