我是 Python 新手,我编写了一个使用 pysftp 模块的脚本。pysftp 模块中有一个函数我遇到了麻烦——它是重命名函数。
这是电话
srv = pysftp.Connection(host = 'xxx.com', username = 'xxx', password = 'xxx')
y = srv.rename('ftptest.txt', 'renamedfile.txt')
我得到的错误是
Traceback (most recent call last):
File "./ftp.py", line 49, in <module>
y = srv.rename('ftptest.txt', 'renamedfile.txt')
File "/usr/local/lib/python2.7/dist-packages/pysftp.py", line 740, in rename
self._sftp.rename(remote_src, remote_dest)
File "/usr/local/lib/python2.7/dist-packages/paramiko/sftp_client.py", line 365, in rename
self._request(CMD_RENAME, oldpath, newpath)
File "/usr/local/lib/python2.7/dist-packages/paramiko/sftp_client.py", line 729, in _request
return self._read_response(num)
File "/usr/local/lib/python2.7/dist-packages/paramiko/sftp_client.py", line 776, in _read_response
self._convert_status(msg)
File "/usr/local/lib/python2.7/dist-packages/paramiko/sftp_client.py", line 804, in _convert_status
raise IOError(errno.EACCES, text)
IOError: [Errno 13] Permission denied
我已经验证该文件存在并且它具有 777 权限。