Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jennyonjourney/dbac1abc04baedb4b01521bc790ab633 to your computer and use it in GitHub Desktop.
Save jennyonjourney/dbac1abc04baedb4b01521bc790ab633 to your computer and use it in GitHub Desktop.
Python - dictionary
dic2 = {'키':157,
'나이':26,
'이름':'이은혜',
'성별':'여자'}
print(dic2)
print(dic2['나이'])
dic2 = {'키':157,
'나이':26,
'이름':'이은혜',
'성별':'여자',
'kk':[11,22,33,44],
#불가능 [234,567]:345,
(234,567):345,
0:3.14}
print(dic2)
print(dic2['키'])
print(dic2[(234,567)])
print(dic2[0])
dic2['국가'] = '대한민국'
print(dic2)
del dic2[(234,567)]
print(dic2)
print(200 in dic2)
print('------keys-------')
kkk = dic2.keys()
print(kkk)
for i in kkk:
print(i)
print('------values-------')
vvv=dic2.values()
print(vvv)
for i in vvv:
print(i)
print('------value만 보기--------')
iii=dic2.items()
print(iii)
for i in iii:
print(i[0], i[1])
print('------key/value 같이 보기------')
for i in dic2:
print(i, dic2[i])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment