python拷贝文件

import shutil, errno

def copyanything(src, dst):
    try:
        shutil.copytree(src, dst)
    except OSError as exc: # python >2.5
        if exc.errno == errno.ENOTDIR:
            shutil.copy(src, dst)
        else: raise
 

代码来源:

http://stackoverflow.com/questions/1994488/copy-file-or-directory-in-python

 

还可以看看这个:

http://stackoverflow.com/questions/123198/how-do-i-copy-a-file-in-python

 

 

你可能感兴趣的:(python)