gevent 传参, 中文编码

 1 #coding=utf-8
 2 import os
 3 from gevent import monkey,pool
 4 monkey.patch_all()
 5 import gevent
 6 import time
 7 p=pool.Pool(5)
 8 print time.strftime('%H:%M:%S')
 9 f=open('d:\\fps.txt','r')
10 wt=open('d:\\fps.html','w')
11 readline=f.readlines()
12 ar=[]
13 for i in readline:
14     ar.append(i.replace('\n',''))
15  
16 f.close()
17 wt.write('<html><body>')
18 def write_to(u):
19     for lists in os.listdir(u):  #WindowsError: [Error 3] : 'u:\\\xe5\x86\x85\xe9\x94\x80\xe7\xb3\xbb\xe5\x88\x97\\W/*.*'...........<Greenlet at 0x63004e0: write_to('u:\\\xe5\x86\x85\xe9\x94\x80\xe7\xb3\xbb\xe5\x88\)> failed with WindowsError
20         path = os.path.join(u, lists)
21         wt.write(path)
22  
23 '''        wt.write('<a href="%s">%s</a><br/>'%(path,lists[:-4]))
24 for u in ar:
25     p.spawn(write_to,u)
26 '''
27  
28 tasks=[p.spawn(write_to,u) for u in ar]
29 gevent.joinall(tasks)
30  
31 wt.write('</body></html>')
32 print time.strftime('%H:%M:%S')
33 del ar
34 wt.close()

 

posted @ 2019-01-23 11:53  wzqwer  阅读(571)  评论(0编辑  收藏  举报