difference_update() 메서드는 두 집합 모두에 있는 항목을 제거합니다.
difference_update() 메서드는 difference() 메서드와 다른데, 아래와 같은 차이점이 있습니다.
매개변수 | 필수 | 설명 |
---|---|---|
set | 필수 | 차이를 체크하기 위한 집합 |
x = {"apple", "banana", "cherry"} y = {"google", "microsoft", "apple"} x.difference_update(y) print(x)
결과
{'banana', 'cherry'}
© 2022 pinfo. All rights reserved.