python标准mysql库从cursor.execute返回元组。要使用question_id字段
row[0],请不要使用
row['question_id']。这些字段的出现顺序与选择语句中出现的顺序相同。
提取多个字段的一种不错的方法是
for row in cursor.execute("select question_id, foo, bar from questions"): question_id, foo, bar = row
python标准mysql库从cursor.execute返回元组。要使用question_id字段
row[0],请不要使用
row['question_id']。这些字段的出现顺序与选择语句中出现的顺序相同。
提取多个字段的一种不错的方法是
for row in cursor.execute("select question_id, foo, bar from questions"): question_id, foo, bar = row