티스토리 뷰

    data0 = {
        'k1': "V1",
        'K2': "V2"
    }
    data01 = {
        'k11': "V11"
    }
    data02 = {
        'k12': "V12"
    }
    '''
    data11 = data0.append(data01) # ==> Exception
    print("[data0]", data0)
    print("[data11]", data11)
    '''
    data12 = data0.update(data02)
    print("[data0]", data0)
    print("[data12]", data12)
    data13 = data0.pop('k12')
    print("[data0]", data0)
    print("[data13]", data13)
    '''
    data14 = data0.pop('k21') # ==> Exception
    print("[data0]", data0)
    print("[data14]", data14)
    '''

<결과>

[data0] {'k1': 'V1', 'K2': 'V2', 'k12': 'V12'}
[data12] None
[data0] {'k1': 'V1', 'K2': 'V2'}
[data13] V12
반응형