zoukankan      html  css  js  c++  java
  • 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('
    ',''))
    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:\xe5x86x85xe9x94x80xe7xb3xbbxe5x88x97\W/*.*'...........<Greenlet at 0x63004e0: write_to('u:\xe5x86x85xe9x94x80xe7xb3xbbxe5x88)> 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()
  • 相关阅读:
    1、Python的初识与简介
    解密解密
    python看是32位还是64
    linux实战一段,安装python3(centos)
    前段技巧
    django后端safe和前端safe的方法
    测试
    python小知识整理
    ajax格式
    111
  • 原文地址:https://www.cnblogs.com/wzbk/p/10308084.html
Copyright © 2011-2022 走看看