返回顶部

收藏

Add new entry to a dictionary

更多
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

标签:Python,Dictionary

收藏

0人收藏

支持

0

反对

0

»更多 您可能感兴趣的代码
  1. 2016-01-18 18:59:48Reference dictionary in print function by 大猪
  2. 2016-08-18 16:22:21Dictionary: items and iteritems by Solon.Ring
  3. 2016-08-19 10:11:08Copy a dictionary by 司马
  4. 2016-09-15 14:35:42Dictionary: values and itervalues by 山药
  5. 2016-01-10 09:34:59If it has a certain key by 张宋付
  6. 2016-02-05 11:12:31Dictionary popitem by xwz
  7. 2016-08-18 16:39:08Dictionary: The keys, values, and items Functions by xwz
  8. 2016-08-31 12:28:03Dictionary has_key method by 山药
  9. 2016-11-25 12:18:57For loop through the dictionary keys by 阮小七
  10. 2016-12-02 09:02:20Update a dictionary by 山药
  11. 2016-08-18 16:51:15Use variable as a key by 阿明娃儿

发表评论