【发布时间】:2016-03-06 05:36:57
【问题描述】:
我目前正在这样做:
cursor.execute('SELECT thing_id, thing_name FROM things')
things = [];
for row in cursor.fetchall():
things.append(dict([('thing_id',row[0]),
('thing_name',row[1])
]))
我可以使用一些速记来做到这一点,或者我应该写一个小辅助函数吗?
【问题讨论】:
标签: python python-2.7 mysql-python