数组如何转字符串

1.通过join

text = mingyan.css(".text::text").extract_first() #提取名言

tags = mingyan.css(".tags.tag::text").extract()#提取标签,结果为数组

tags = ','.join(tags) #数组转换为字符串

2.通过for循环

item['bansui_symptons'] = response.xpath(
    "//*[@class='dis']//tr[" + str(i + 2) + "]/td[2]/a/@title").extract()
# 依次遍历所有的症状
str2 = ''
for j in item['bansui_symptons']:
    str2 += j + '   '

item['bansui_symptons'] = str2

猜你喜欢

转载自blog.csdn.net/u014229742/article/details/81939438
今日推荐