Python 'list' cannot be converted to a MySQL type

   def process_item(self, item, spider):
       #1.Python 'list' cannot be converted to a MySQL type
        # self.cur.execute("insert into info values (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)",
        #                  (item['xh'],item['sgdm'],item['zqdm'],item['name'],item['wsfxr'],item['ssr'],
        #                   item['fxl'],item['wsfxl'],item['sgsx'],item['fxj'],item['syl'],item['zql']))

       #2.ok
        values  = [item['xh'][0], item['sgdm'][0], item['zqdm'][0], item['name'][0], item['wsfxr'][0], item['ssr'][0],item['fxl'][0],
                   item['wsfxl'][0], item['sgsx'][0], item['fxj'][0], item['syl'][0], item['zql'][0]]
        self.cur.execute("insert into info values (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)",values)
        self.conn.commit()

你可能感兴趣的:(Python 'list' cannot be converted to a MySQL type)