首页 > 代码库 > 字典 习题

字典 习题

字典习题:已知字典:ainfo = {ab:liming,ac:20}完成下面的操作1 使用2个方法,输出的结果:ainfo = {ab:liming,ac:20,sex:man,age:20}2 输出结果:[ab,ac]3 输出结果:[liming,20]4 通过2个方法返回键名ab对应的值。5 通过2个方法删除键名ac对应的值。ainfo = {ab:liming,ac:20}binfo = {ab:liming,ac:20}ainfo[sex] = manainfo[age] = 20print ainfoprint binfo.keys()print binfo.values()print ainfo[ab]del ainfo[ac]print ainfo

 

字典 习题