import shelve# 新增# m = shelve.open("database", writeback=True)# m["k1"] = "v1"# m.close()# 查询m = shelve.open("database", writeback=True)print(m["k1"]) # v1m.close()# 修改# m = shelve.open("database", writeback=True)# m["k1"] = "value1"# m.close()# 查询m = shelve.open("database", writeback=True)print(m["k1"]) # value1m.close()# 新增# m = shelve.open("database", writeback=True)# m["k2"] = {"k1":"v1","k2":"v2","k3":"v3","k4":{"a1":"b1","a2":"b2"}}# m.close()# 查询m = shelve.open("database", writeback=True)print(m["k2"]) # value1m.close()# 修改# m = shelve.open("database", writeback=True)# m["k2"]["k4"]["a2"] = "B" # value1# m.close()# 查询m = shelve.open("database", writeback=True)print(m["k2"]) # value1m.close()