嗨,我试着从一个粗糙的项目中提取信息。
我试着
dre = [i.split(', ') for i in response.xpath('normalize-space(//*[contains(@class,"business-address")])').extract()]
ml_item['address'] = dre[0]输出:
'address': ['Calle V Centenario 24', '46900', 'Torrente', 'Valencia']我需要将此输出中的信息保存在不同的变量逗号分隔的ml_item['cp'] = '46900'、ml_item['city'] = 'Torrente'中
发布于 2020-04-20 20:38:42
如果dre[0]给你['Calle V Centenario 24', '46900', 'Torrente', 'Valencia'],那么
ml_item['cp'] = dre[0][1]
ml_item['city'] = dre[0][2]或
ml_item['address'] = dre[0]
ml_item['cp'] = ml_item['address'][1]
ml_item['city'] = ml_item['address'][2]https://stackoverflow.com/questions/61322344
复制相似问题