推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
Yycreater
V2EX  ›  Python

进程池问题~~~

  •  
  •   Yycreater ·
    Yycreater · Apr 26, 2018 · 2020 views
    This topic created in 2944 days ago, the information mentioned may be changed or developed.
    #使用进程池将一个目录复制到其他目录下
    def myCopy(file):
    # 文件与旧路径拼接为绝对路径
    newSrcpath = os.path.join(src, file)
    # 文件与旧路径拼接为绝对路径
    newDispath = os.path.join(dst, file)

    open(newDispath, 'wb').write(open(newSrcpath, 'rb').read())
    print('文件写入完成')

    src = r'C:\Users\様\Desktop\md 集合'
    dst = r'D:\Class 资料\多线程测试'

    if __name__ == '__main__':
    start = time.time()
    #读取文件以列表形式返回
    fileList = os.listdir(src)
    #创建线程池
    pp = Pool()
    #开启线程池
    pp.map(myCopy,fileList)
    pp.close()
    pp.join()
    end = time.time()
    print('用时', end - start, '秒')
    print('OVER')


    我想用进程池实现一个将一个目录下的所有文件复制到另一个目录的文件下,还是用多进程改的,结果报了许多语法错误~求 dalao 帮忙看一下~~~给点意见
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1182 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 23:12 · PVG 07:12 · LAX 16:12 · JFK 19:12
    ♥ Do have faith in what you're doing.