【发布时间】:2017-09-18 17:53:03
【问题描述】:
如何在 Python 中递归复制目录 (cp -r)?
os.copytree 产生FileExistsError: [Errno 17] File exists:。
而distutils.dir_util.copy_tree 引发AttributeError: module 'distutils' has no attribute 'dir_util'
如何在 Python 中对cp -r 执行 linux 等效操作?
【问题讨论】:
-
使用子进程的一种方法是:
import subprocesssubprocess.call('cp -r source destination', shell=True) -
system("cp -r")可能适合你
标签: python linux python-3.x file-copying