- 帖子
- 6
- 精华
- 0
- 积分
- 53
- 阅读权限
- 20
- 注册时间
- 2017-9-13
- 最后登录
- 2017-12-12
|
本帖最后由 silen_lu 于 2017-9-15 17:09 编辑
照敲的代码,怎么返回结果就是不一样呢?方法中 print i,time.time()-time_start print 'data:',len(data) 这两行代码的数据为啥是程序运行结束后按ENTER后才输出的一坨呢?
下面是我的代码:
import time,urllib,thread
def get_content(i):
id = 1764796+i
url='https://api.douban.com/v2/movie/subject/%d'%id
d=urllib.urlopen(url).read()
data.append(d)
print i,time.time()-time_start
print 'data:',len(data)
time_start=time.time()
data=[]
for i in range(30):
print 'request movie:',i
thread.start_new_thread(get_content,(i,))
raw_input('press ENTER to exit...\n')
我的返回结果(求指教):
request movie: 0
request movie: 1
request movie: 2
request movie: 3
request movie: 4
request movie: 5
request movie: 6
request movie: 7
request movie: 8
request movie: 9
request movie: 10
request movie: 11
request movie: 12
request movie: 13
request movie: 14
request movie: 15
request movie: 16
request movie: 17
request movie: 18
request movie: 19
request movie: 20
request movie: 21
request movie: 22
request movie: 23
request movie: 24
request movie: 25
request movie: 26
request movie: 27
request movie: 28
request movie: 29
press ENTER to exit...(此处按回车后python shell继续返回下面的数据:)
10119511141392318626243282721207151716825222294120
>>> 9.934999942789.934999942789.934999942789.934999942789.934999942789.934999942789.934999942789.934999942789.934999942789.934999942789.934999942789.934999942789.934999942789.934999942789.934999942789.934999942789.934999942789.934999942789.934999942789.934999942789.934999942789.934999942789.934999942789.934999942789.95099997529.95099997529.95099997529.95099997529.95099997529.9509999752
data:data:data:data:data:data:data:data:data:data:data:data:data:data:data:data:data:data:data:data:data:data:data:data:data:data:data:data:data:data: 303030303030303030303030303030303030303030303030303030303030
|
|