popitem() 메서드는 사전에 마지막으로 삽입된 항목을 제거합니다.
3.7 이전 버전에서는 popitem() 메서드가 랜덤 항목을 제거합니다.
매개변수는 없습니다.
제거된 항목의 튜플값
car = { "brand": "Ford", "model": "Mustang", "year": 1964 } car.popitem() print(car)
결과
{'brand': 'Ford', 'model': 'Mustang'}
car = { "brand": "Ford", "model": "Mustang", "year": 1964 } x = car.popitem() print(x)
결과
('year', 1964)
© 2022 pinfo. All rights reserved.