Add new entry to a dictionary

2019-06-19 20:03栏目:技术创新
TAG:

d2 = {'spam': 2, 'ham': 1, 'eggs': 3}    # make a dictionary

print d2                                       # order is scrambled

d2['ham'] = ['grill', 'bake', 'fry']      # change entry

del d2['eggs']                            # delete entry

d2['brunch'] = 'Bacon'                    # add new entry

print d2

版权声明:本文由新浦京娱乐站_新浦京娱乐场官网_新浦京娱乐发布于技术创新,转载请注明出处:Add new entry to a dictionary