no message
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
contacts = {
|
||||
'name':'张三',
|
||||
'sex':"男",
|
||||
'salary':'8000'
|
||||
}
|
||||
print(contacts.pop('name')) # 删除键值对,返回值
|
||||
del contacts['sex'] # 删除键值对
|
||||
print(contacts)
|
||||
|
||||
# pop能返回被删除的值,而del不能返回被删除的值
|
||||
# pop()能指定默认值,而del不能指定默认值
|
||||
Reference in New Issue
Block a user