该MySQLdb的模块具有DictCursor:
像这样使用它(摘自使用Python DB-
API编写MySQL脚本):
cursor = conn.cursor(MySQLdb.cursors.DictCursor)cursor.execute("SELECt name, category FROM animal")result_set = cursor.fetchall()for row in result_set: print "%s, %s" % (row["name"], row["category"])编辑: 根据user1305650这也适用
pymysql。



