1. 代码(参考:https://www.cnblogs.com/xiao-xue-di/p/11840699.html)
def dict_fetchall(cursor): "Return all rows from a cursor as a dict" columns = [col[0] for col in cursor.description] return [ dict(zip(columns, row)) for row in cursor.fetchall() ]
1. 代码(参考:https://www.cnblogs.com/xiao-xue-di/p/11840699.html)
def dict_fetchall(cursor): "Return all rows from a cursor as a dict" columns = [col[0] for col in cursor.description] return [ dict(zip(columns, row)) for row in cursor.fetchall() ]