존재하는 경우 파이썬 세트 제거

코드 예제

7
0

파이썬 세트 제거

s = {0, 1, 2}
s.discard(0)  
print(s)
{1, 2}

# discard() does not throw an exception if element not found
s.discard(0)

# remove() will throw
s.remove(0)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
KeyError: 0
6
0

파이썬에서 요소 양식 세트 제거

list1 = {1,2,3,4}
list1.remove(4)
print(list)
# {1,2,3}
4
0

세트 파이썬에서 항목 제거

# it doesn't raise error if element doesn't exits in set

thisset = {1, 2,3}

thisset.discard(3)

print(thisset)
1
0

파이썬 제거 설정

s = set()
s.remove(x)
0
0

세트 파이썬에서 요소 삭제 및 반환

>>> s = set([1])
>>> print s.pop()
1
>>> print s
set([])
>>> print s.pop()
KeyError: pop from an empty set
0
0

존재하는 경우 파이썬 세트 제거

set.discard('element')

다른 언어로

이 페이지는 다른 언어로되어 있습니다

Русский
..................................................................................................................
English
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................