1 回答
TA贡献1868条经验 获得超4个赞
供将来参考,像这样解决它:
for item in registros:
armadilhafields = [
item['id'],
item['name'],
item['image'],
item['category_id'],
item['category']['name'],
item['location']['lat'],
item['location']['lng'],
item['files'][0]['url_orig'],
item['info'][0]['value'],
item['info'][1]['value'],
item['info'][2]['value'],
item['info'][3]['value'],
item['info'][4]['value'],
item['info'][5]['value'],
item['info'][6]['value'],
item['info'][7]['value'],
item['info'][8]['value'],
item['info'][9]['value'],
item['info'][10]['value'],
]
my_data = [field for field in armadilhafields]
cur.execute("INSERT INTO egrfauna_armadilhas VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", tuple(my_data))
conn.commit()
添加回答
举报