上一页 1 ··· 4 5 6 7 8
摘要: import timefrom concurrent.futures import ThreadPoolExecutor, as_completedfrom concurrent.futures import ProcessPoolExecutordef f... 阅读全文
posted @ 2015-12-11 19:55 Jeff_blog 阅读(137) 评论(0) 推荐(0) 编辑
摘要: 1 import multiprocessing 2 import os 3 import time 4 5 6 def get_html(n): 7 time.sleep(n) 8 print('sub_progress success') 9 return n 10 11 12 if __nam 阅读全文
posted @ 2015-12-10 15:25 Jeff_blog 阅读(105) 评论(0) 推荐(0) 编辑
摘要: 使用场景:比如在调用网络API时,提高成功率。 import requests from datetime import datetime import time import random retry_timeout = 10 def http_request(url, first_request 阅读全文
posted @ 2015-12-06 16:33 Jeff_blog 阅读(240) 评论(0) 推荐(0) 编辑
摘要: from threading import Lock,RLockimport threadingimport timetotal = 0lock = RLock()def add(): global total global lock fo... 阅读全文
posted @ 2015-12-03 01:30 Jeff_blog 阅读(92) 评论(0) 推荐(0) 编辑
摘要: 前言: 《Python网络编程 》介绍了网络编程基础,并提供了代码示例。很喜欢的一点是提供了一个网络实验环境。 1. 编码与解码 解码(decoding)是在应用程序使用字节时发生的。 编码(encoding)是程序将字符串对外输出时所实施的过程。 2. 路由 根据目的IP地址选择将IP数据包发往何 阅读全文
posted @ 2015-12-01 19:17 Jeff_blog 阅读(93) 评论(0) 推荐(0) 编辑
摘要: def g1(iterable): yield iterable def g2(iterable): yield from iterable for value in g1(range(10)): print(value) for value in g2(range(10)): print(valu 阅读全文
posted @ 2015-11-30 18:21 Jeff_blog 阅读(99) 评论(0) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8