Copy an entire directory tree src to a
new location dst. Both src and dst
must be directory names. If src is not
a directory, raise DistutilsFileError.
If dst does not exist, it is created
with mkpath(). The end result of the
copy is that every file in src is
copied to dst, and directories under
src are recursively copied to dst.
Return the list of files that were
copied or might have been copied,
using their output name. The return
value is unaffected by update or
dry_run: it is simply the list of all
files under src, with the names
changed to be under dst.
对于像这样的高级文件操作,使用shutil模块和copytree函数。我认为这比“滥用”distutils更干净。
更新::忘记答案,我忽略了OP确实尝试过shuil。
为什么不自己使用
os.walk
实现呢?^{} 做你想做的事。
(更多文档请访问上述url)
相关问题 更多 >
编程相关推荐