1.Request 需要:from scrapy.http.request import Request
yield使用:
1.不使用yield:
def fab(max): n, a, b = 0, 0, 1 L = [] while n < max: L.append(b) a, b = b, a + b n = n + 1 return L for n in fab(5): print n
def fab(max): n, a, b = 0, 0, 1 while n < max: yield b # print b a, b = b, a + b n = n + 1 for n in fab(5): print n
则yield b 相当于创建了一个列表,并且把b的值append到列表中了