python 基础
一直在路上ha~
这个作者很懒,什么都没留下…
展开
-
使用多进程,多线程和协程实现爬虫,使用queue完成数据通信
一直在看python的多进程,多线程和协程,动手试了试写个爬虫练习一下。 多线程版本 import ssl import threading import time import urllib.request from queue import Queue from lxml import etree class myThread(threading.Thread): def ...原创 2019-02-26 17:00:14 · 654 阅读 · 0 评论 -
Python进阶--生成器和迭代器以及实现方法
生成器和迭代器 generator: ⽣成器是一种特殊的迭代器, 不需要⾃定义 __iter__ 和 __next__ ⽣成器函数 (yield) def foo(): ...: print(111) ...: yield 222 ...: print(333) ...: yield 444 ...: p...原创 2019-02-26 18:26:19 · 206 阅读 · 0 评论