파이썬 세트 제거
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
파이썬에서 요소 양식 세트 제거
list1 = {1,2,3,4}
list1.remove(4)
print(list)
# {1,2,3}
세트 파이썬에서 항목 제거
# it doesn't raise error if element doesn't exits in set
thisset = {1, 2,3}
thisset.discard(3)
print(thisset)
파이썬 제거 설정
s = set()
s.remove(x)
세트 파이썬에서 요소 삭제 및 반환
>>> s = set([1])
>>> print s.pop()
1
>>> print s
set([])
>>> print s.pop()
KeyError: pop from an empty set
존재하는 경우 파이썬 세트 제거
set.discard('element')