Python程序设计-第2章-使用序列-2(第4次课).pptVIP

  • 3
  • 0
  • 约1.19万字
  • 约 48页
  • 2019-10-24 发布于山东
  • 举报

Python程序设计-第2章-使用序列-2(第4次课).ppt

2.5 字典 (7)删除元素和字典 可以使用del语句删除指定键的元素或整个字典 使用clear( )方法来删除字典中所有元素 使用pop ()方法删除并返回指定键的元素。 例如 del a_dict[‘server’]将删除键值为‘server’的元素 a_dict.pop(‘database’)将删除并返回健为‘database’的元素 a_dict.clear()将删除字典中所有元素,del a_dict将删除整个字典。 del a_dict[server] a_dict {database: blog, user: mark} a_dict.pop(database) blog a_dict {user: mark} a_dict.clear( ) a_dict { } del a_dict a_dict Traceback (most recent call last): File pyshell#103, line 1, in module a_dict NameError: name a_dict is not defined a_dict= {database: blog, server: db.diveintopython3.org, user: mark} 2.6 The application of array 【EG2-1】S

文档评论(0)

1亿VIP精品文档

相关文档