python字典应该如何存储在pytables中?

python字典应该如何存储在pytables中?,python,dictionary,pytables,Python,Dictionary,Pytables,pytables本机不支持python字典。我采用的方法是制作表单的数据结构: tables_dict = { 'key' : tables.StringCol(itemsize=40), 'value' : tables.Int32Col(), } (注意,我确保键是的,您可以要求PyTables在表内搜索,还可以在键列上创建索引以加快搜索速度 要创建索引,请执行以下操作: table.cols.key.createIndex() 要查询key等于变量searc

pytables本机不支持python字典。我采用的方法是制作表单的数据结构:

tables_dict = {
'key'         : tables.StringCol(itemsize=40),
'value'       : tables.Int32Col(),
}

(注意,我确保键是的,您可以要求PyTables在表内搜索,还可以在键列上创建索引以加快搜索速度

要创建索引,请执行以下操作:

table.cols.key.createIndex()
要查询
key
等于变量
search\u key
的值:

[row['value'] for row in table.where('key == search_key')]

dict(file_handle.dictionary.read())
table.cols.key.createIndex()
[row['value'] for row in table.where('key == search_key')]