1 回答

TA貢獻(xiàn)1868條經(jīng)驗(yàn) 獲得超4個(gè)贊
供將來參考,像這樣解決它:
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()
添加回答
舉報(bào)