字典也有pop
pop(key[,default])
a = {1:2,3:4,5:6}
b = a.pop(3,None)
a
输出:
{1: 2, 5: 6}
没有key
a = {1:2,3:4,5:6}
b = a.pop(7,None)
a
输出:
{1: 2, 3: 4, 5: 6}
字典也有pop
pop(key[,default])
a = {1:2,3:4,5:6}
b = a.pop(3,None)
a
输出:
{1: 2, 5: 6}
没有key
a = {1:2,3:4,5:6}
b = a.pop(7,None)
a
输出:
{1: 2, 3: 4, 5: 6}
本文标题:python 字典 pop
本文链接:https://www.haomeiwen.com/subject/fyyjzftx.html
网友评论