摘要: def create_num(all_num): print(' 1 ') a, b = 0, 1 current_num = 0 while current_num < all_num: print(' 2 ') yy = yield a # 如果函数中 有yield 语句,那么就不再是函数了,而 阅读全文
posted @ 2019-11-01 10:24 fuyouqiang 阅读(449) 评论(0) 推荐(0)
摘要: class Fibonacci(object): def __init__(self, all_num): self.all_num = all_num self.current_num = 0 self.a = 0 self.b = 1 def __iter__(self): return sel 阅读全文
posted @ 2019-11-01 00:23 fuyouqiang 阅读(612) 评论(0) 推荐(0)
摘要: import osimport multiprocessingdef copy_filename(q, filename, old_filename, new_filename): old_f = open(old_filename + '/' + filename, 'rb') content = 阅读全文
posted @ 2019-10-31 18:02 fuyouqiang 阅读(243) 评论(0) 推荐(0)
摘要: from multiprocessing import Poolimport os, time, randomdef worker(msg): t_start = time.time() print('{}开始执行,进程号为 {}'.format(msg, os.getpid())) # rando 阅读全文
posted @ 2019-10-31 16:52 fuyouqiang 阅读(360) 评论(0) 推荐(0)
摘要: import multiprocessingdef download_date(q): ''' 下载数据 ''' # 模拟从网上下载数据 data = [11, 22, 33, 44] # 向队列中写入数据 for temp in data: q.put(temp) print(' 已经下载完毕-- 阅读全文
posted @ 2019-10-31 15:33 fuyouqiang 阅读(279) 评论(0) 推荐(0)
摘要: import multiprocessingimport timedef test1(): while True: print('1 ') time.sleep(1)def test2(): while True: print('2 ') time.sleep(1)def main(): p1 = 阅读全文
posted @ 2019-10-31 15:05 fuyouqiang 阅读(242) 评论(0) 推荐(0)
摘要: import threadingimport time# 定义一个全局变量g_num = 0def test1(num): global g_num for i in range(num): g_num += 1 print(' in test1 g_num={}'.format(g_num))de 阅读全文
posted @ 2019-10-31 12:01 fuyouqiang 阅读(401) 评论(0) 推荐(0)
摘要: import threadingimport time# 定义一个变量nums = [11, 22]def test1(nums): nums.append(33) print(' in test1 num={} '.format(nums))def test2(): print(' in test 阅读全文
posted @ 2019-10-31 11:43 fuyouqiang 阅读(1148) 评论(0) 推荐(0)
摘要: num = 100nums = [11, 22]def test1(num): num += 1def test2(): global num num += 1def test3(nums): nums += [33]def test4(): global nums nums += [33]def 阅读全文
posted @ 2019-10-31 10:59 fuyouqiang 阅读(2625) 评论(0) 推荐(0)
摘要: import threadingimport timedef test1(): for i in range(5): print(' test1 {}'.format(i)) time.sleep(1)def test2(): for i in range(10): print(' test2 {} 阅读全文
posted @ 2019-10-31 10:22 fuyouqiang 阅读(2485) 评论(0) 推荐(0)