Вопрос

I'd like to copy all files in my present working directory to another location.

I have tried variations of the below:

import shutil
shutil.copyfile('/*','/my/other/directory/location')

This gives the error: OSError: [Errno 2] No such file or directory: '/*'

I am thinking about using os.system and the cp command.

Has anyone got any better ideas?

Это было полезно?

Решение

I would use shutil. Is there a problem with that ?

Personally I tend to use:

shutil.copytree(src, dst, symlinks=False, ignore=None)

as it takes subdirs

update------

To get the current working directory use

os.getcwd()
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top