字典类型:dict
Python字典的增删改查
增:
1 | stu = {"name":"Rose"} |
删:
1 | stu = {"name":"Rose", "age":22} |
提示:如果删除的是不存在的key,则会报错
改:
1 | stu = {"name":"Rose", "age":22} |
查:
1 | stu = {"name":"Rose", "age":22} |
提示:使用这种查询方法,如果键不存在,则会报错
1 | "name":"Rose", "age":22} stu = { |
1 | "name":"Rose", "age":22} stu = { |
提示:使用这种查询方法,如果键不存在,不会报错
查询字典当中是否存在某个键:
1 | "name":"Jack", "age":"22"} stu = { |
1 | "name":"Jack", "age":"22"} stu = { |
查询字典当中是否存在某个值:
1 | "name":"Jack", "age":"22"} stu = { |