zoukankan      html  css  js  c++  java
  • 初识python yield

    
    
    for sel in response.xpath('//ul/li'):
        item = DmozItem()
        item['title'] = sel.xpath('a/text()').extract()
        item['link'] = sel.xpath('a/@href').extract()
        item['desc'] = sel.xpath('text()').extract()
        yield item


    等价于:

    items []
    for sel in response.xpath('//ul/li'):
        item = DmozItem()
        item['title'] = sel.xpath('a/text()').extract()
        item['link'] = sel.xpath('a/@href').extract()
        item['desc'] = sel.xpath('text()').extract()
       items.append(item)
        return items

    就这么简单!
  • 相关阅读:
    velocity .vm
    @Autowired
    springMVC
    索引
    Adivisor
    计算火车运行的时间
    倒三角
    XML简介
    表单提交方式
    js动态生成表格
  • 原文地址:https://www.cnblogs.com/yrqiang/p/5297526.html
Copyright © 2011-2022 走看看