说明:1、yield,将函数变为 generator (生成器)
例如:斐波那契数列
def fib(num):
a, b, c = 1, 0, 1
while a <= num:
yield c
b, c = c, b + c
a += 1
for n in fib(10):
print(n, end=' ')
# 1 1 2 3 5 8 13 21 34 55
2、Iterable
所有可以使用for循环的对象,统称为 Iterable (可迭代 <weixin_38499706> 上传 | 大小:40kb
说明:本文实例讲述了python开发之基于thread线程搜索本地文件的方法。分享给大家供大家参考,具体如下:
先来看看运行效果图:
利用多个线程处理搜索的问题,我们可以发现他很快….
下面是代码部分:
# A parallelized "find(1)" using the thread module.
# This demonstrates the use of a work queue and worker threads.
# It really does do more stats/se <weixin_38678300> 上传 | 大小:107kb