Scrapy 作为元组而不是列表输出的零散项

Scrapy 作为元组而不是列表输出的零散项,scrapy,Scrapy,无论出于何种原因,所有项都以元组的形式返回。不知道我错过了什么。在所有其他spider和项目中,它只是一个列表(当我使用extract()时) 这是我的蜘蛛代码 def parse(self, response): inspect_response(response, self) a = response.xpath('//table//tr') for i in a: item = CosdnaExtItem() item['name'

无论出于何种原因,所有项都以元组的形式返回。不知道我错过了什么。在所有其他spider和项目中,它只是一个列表(当我使用extract()时)

这是我的蜘蛛代码

def parse(self, response):
    inspect_response(response, self)
    a = response.xpath('//table//tr')

    for i in a:
        item = CosdnaExtItem()
        item['name'] = i.xpath('./td/a/text()').extract_first(),
        item['url'] = i.xpath('./td/a/@href').extract_first(),
        item['function'] = i.xpath('.//td[2]/span//text()').extract(),
        item['acne'] = i.xpath('.//td[3]/span//text()').extract_first(),
        item['irritant'] = i.xpath('.//td[4]/span//text()').extract_first(),
        item['safety'] =  i.xpath('.//td[5]/div//text()').extract_first(),

        yield item

请注意,行尾有额外的逗号:

item['function'] = i.xpath('.//td[2]/span//text()').extract(),
用Python

x = y,
x = (y,)


请注意,行尾有额外的逗号:

item['function'] = i.xpath('.//td[2]/span//text()').extract(),
用Python

x = y,
x = (y,)