为什么shutil.copy()会在cp没有时引发权限异常?

9 浏览
0 Comments

为什么shutil.copy()会在cp没有时引发权限异常?

shutil.copy()抛出了一个权限错误:

Traceback (most recent call last):
  File "copy-test.py", line 3, in 
    shutil.copy('src/images/ajax-loader-000000-e3e3e3.gif', 'bin/styles/blacktie/images')
  File "/usr/lib/python2.7/shutil.py", line 118, in copy
    copymode(src, dst)
  File "/usr/lib/python2.7/shutil.py", line 91, in copymode
    os.chmod(dst, mode)
OSError: [Errno 1] Operation not permitted: 'bin/styles/blacktie/images/ajax-loader-000000-e3e3e3.gif'

copy-test.py:

import shutil
shutil.copy('src/images/ajax-loader-000000-e3e3e3.gif', 'bin/styles/blacktie/images')

我从命令行运行copy-test.py:

python copy-test.py

但是在命令行上使用相同的文件和目的地运行cp不会导致错误。为什么?

0