• 회원가입
  • 로그인
  • 구글아이디로 로그인

[dictionary] Python - dictionary.popitem() 메서드 - Dictionary 마지막 item 제거. (= popitem메서드 = 딕셔너리팝아이템메서드) ※ 마지막 아이템 제거

2735  
목차
  1. dictionary.popitem() 예제 - 마지막 item 제거
  2. dictionary.popitem() 정의
  3. dictionary.popitem() 구문
  4. dictionary.popitem() 예제 - 제거된 item 반환

 

dictionary.popitem() 예제 - 마지막 item 제거

 

hz ={

  "site": "홈짱닷컴",

  "host": "Homzzang.com",

  "open": 2012

}

hz.popitem()

print(hz)

 

결과값: {'site': '홈짱닷컴', 'host': 'Homzzang.com'}

 

dictionary.popitem() 정의

 

Dictionary의 마지막 item 제거 후, 제거된 item 반환.

cf. 

Python 3.7 이전 버전 경우, 랜덤으로 Item 제거.

 

 

dictionary.popitem() 구문

 

dictionary.popitem()

 


[매개변수]

 

없음.

 

 

dictionary.popitem() 예제 - 제거된 item 반환

 

hz ={

  "site": "홈짱닷컴",

  "host": "Homzzang.com",

  "open": 2012

}

x = hz.popitem()

print(x)

 

반환값: ('open', 2012)

 


분류 제목
basic Python - Home (입문) - 이념 / 추천 링크
basic Python - Intro (소개) - 용도・특징
basic Python - Start (시작) - 파이썬 설치/실행/버전확인
basic Python - Syntax (구문) - 들여쓰기・변수・주석
basic Python - Comment (주석)
basic Python - Variable (변수)
basic Python - DataType (데이터타입) - 자료형
basic Python - Number (숫자)
basic Python - Casting (데이터 타입 변경) - 자료형 변환
basic Python - String (문자열) ★ ※ 색인번호 (= 인덱스) 개념.
basic Python - Boolean (참거짓)
basic Python - Operator (연산자)
basic Python - List (리스트) ★ - 변경 가능한 모음
basic Python - Tuple (투플/튜플) - 변경 불가 모음
basic Python - Set (셋/세트) - '순서(=색인)' 없고, 중복 허용 않는 데이터 모음.
basic Python - Dictionary (딕셔너리) - Key:value 쌍으로 구성된 모음
basic Python - if...elif...else - (이프조건문) ※ 3항연산자 = 삼항연산자
basic Python - While (와일반복문) - 와일문
basic Python - For (포반복문) ★★★★★
basic Python - Function (함수)
1/24
목록
찾아주셔서 감사합니다. Since 2012