推荐学习书目
› 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
qazwsxkevin
V2EX  ›  Python

请教复制、移动文件的方法?

  •  
  •   qazwsxkevin · Feb 13, 2020 · 3708 views
    This topic created in 2455 days ago, the information mentioned may be changed or developed.
    shutil.copyfile(),如果 dst 是一个多层级的目录,其中几层没有建立,
    shutil.copyfile()似乎并不支持直接创建,用什么更好的轮子可以直接完成呢?
    如果是移动文件呢?
    自己写 if os.path.exist()加上 os.mkdirs 也不是难的,只是小文件量大( 400 多万个小文件吧),前面已经做了很多 if 判断,感觉自己水平再写个东西去做判断,有拖腿感觉.
    5 replies  •  2020-02-13 19:05:33 +08:00
    milu123
    milu123
    Feb 13, 2020
    1
    fs-extra 库有 ensureDir 方法
    https://www.npmjs.com/package/fs-extra
    wuwukai007
    wuwukai007
    Feb 13, 2020
    2
    shutil.copytree 应该可以复制多层目录的
    leido
    leido
    Feb 13, 2020 via Android
    3
    二楼正解
    v22ex6667
    v22ex6667
    Feb 13, 2020
    4
    直接调用系统的 复制,移动效率如何?
    yzwduck
    yzwduck
    Feb 13, 2020
    5
    试试调用外部工具? Windows 有 FastCopy,其他系统基本都有 rsync。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   5404 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 03:21 · PVG 11:21 · LAX 19:21 · JFK 22:21
    ♥ Do have faith in what you're doing.