[python 기초] python의 dictionary에 대하여
Ditionary{1:one, 2:two}mapping: key값을 가지고 찾음! 1. 기본적인 사용 방법: {}12345678910111213141516171819202122months = {1:'Jan', 2:'Feb', 3:'Mar', 4:'Apr', 5:'May', 6:'Jun', 7:'Jul', 8:'Aug', 9:'Sep', 10:'Oct', 11:'Nov', 12:'Dec'} print(months[1]) #Jan items = [('name', 'May'), ('birth', 5)]dict_items = dict(items)print(dict_items) # {'name': 'May', 'birth': 5}print(len(dict_items)) # 2 del dict_items['birt..
2018. 6. 28.
[python 기초] python의 tuple에 대하여
TupleTuple은 ()를 통해 만들거나, ","를 이용하여 만들 수 있다. 123456789101112131415161718192021222324a = 1b = 1,print(type(a), a) # 1print(type(b), b) # (1,) c = 4 * (20+5)d = 4 * (20+5,)print(type(c), c) # 100print(type(d), d) # (25, 25, 25, 25) e = [1, 2, 3]f = tuple(e)print(type(e), e) # [1, 2, 3]print(type(f), f) # (1, 2, 3) print(list('hello')) # ['h', 'e', 'l', 'l', 'o']print(tuple('hello')) # ('h', 'e', 'l..
2018. 6. 27.