[Python]๋”•์…”๋„ˆ๋ฆฌ์˜ ๋ฉ”์†Œ๋“œ

2024. 4. 11. 17:18ใ†[๐Ÿ’ปPython] pearl's python ๋ณ‘์•„๋ฆฌ ํƒˆ์ถœ๊ธฐ ๐Ÿฃ

person = {'์ด๋ฆ„' : 'ํ™๊ธธ๋™', '๋‚˜์ด' :26, '๋ชธ๋ฌด๊ฒŒ': 82}

<keys>
person.key()
#์˜ˆ์ƒ ์ถœ๋ ฅ : dict_keys(['์ด๋ฆ„', '๋‚˜์ด', '๋ชธ๋ฌด๊ฒŒ'])

<values>
person.value()
#์˜ˆ์ƒ ์ถœ๋ ฅ : dict_values(['ํ™๊ธธ๋™', 26, 82])

<items>
person.items()
#์˜ˆ์ƒ ์ถœ๋ ฅ : dict_items([('์ด๋ฆ„', 'ํ™๊ธธ๋™'), ('๋‚˜์ด', 26), ('๋ชธ๋ฌด๊ฒŒ', 82)])

<get>
print(person.get("์ด๋ฆ„"))
#์˜ˆ์ƒ ์ถœ๋ ฅ : ํ™๊ธธ๋™

<pop>
print(person.pop("์ด๋ฆ„"))
person
#์˜ˆ์ƒ ์ถœ๋ ฅ : 
ํ™๊ธธ๋™
{'๋‚˜์ด': 26, '๋ชธ๋ฌด๊ฒŒ': 82}

<popitems>
print(person.popitem())
person
# ์˜ˆ์ƒ ์ถœ๋ ฅ : 
('๋ชธ๋ฌด๊ฒŒ', 82)
{'๋‚˜์ด': 26}

<clear>
print(person.clear())
#์˜ˆ์ƒ ์ถœ๋ ฅ : 
None