import time
import numpy as np
import cv2
import requests
urls=["http://www.pptbz.com/pptpic/UploadFiles_6909/201203/2012031220134655.jpg","http://pic22.nipic.com/20120714/9622064_105642209176_2.jpg","http://pic104.nipic.com/file/20160715/6171480_185807154956_2.jpg",
"http://www.pptbz.com/pptpic/UploadFiles_6909/201203/2012031220134655.jpg"]
for i in urls:
start=time.time()
file = requests.get(i)
img = cv2.imdecode(np.fromstring(file.content, np.uint8), 1) #file.content 是读取的远程文件的字节流
print('time',time.time()-start)
时间:
time 0.4249999523162842
time 0.546999454498291
time 0.5099942684173584
time 0.3