Questions tagged «dataformat»

14
如何从sqlite查询中获取字典?
db = sqlite.connect("test.sqlite") res = db.execute("select * from table") 通过迭代,我得到了对应于行的列表。 for row in res: print row 我可以得到列的名称 col_name_list = [tuple[0] for tuple in res.description] 但是是否有一些功能或设置可以获取字典而不是列表? {'col1': 'value', 'col2': 'value'} 还是我必须自己做?
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.