标签:decode 路径 进入 def port ret www. 请求 python程序
今天, 使用python3
模拟下发包, http get
请求, 然后 采用tomorrow
多线程.
# coding=utf-8
from urllib import request
import json
from tomorrow import threads
import time
@threads(100)
def testgetHtml(url):
requests = request.urlopen(url)
return requests
start = time.time()
url = "https://www.baidu.com/"
print('begin')
responses = [testgetHtml(url) for i in range(100)]
# html = [(json.loads(response.read().decode('utf-8')))['total']
html = [response.read().decode('utf-8') for response in responses]
for x in html:
print(x)
tomorrow
包准备pip install tomorrow
tomorrow
包, 开始怀疑默认pip路径安装问题. 解决方法步骤如下:
path
系统环境, 修改python 及 python\scripts 的路径, 不生效, 错误依旧.pip
. 方法: pip 官网下载后, 解压.tar.gz
的格式, 然后 python setup.py install
安装成功, 错误消失标签:decode 路径 进入 def port ret www. 请求 python程序
原文地址:https://www.cnblogs.com/hijushen/p/10468661.html