Downloading file with pysftp

陌路散爱 提交于 2019-12-03 03:08:20

Connection.get does not return anything. It downloads the remote file to a local path specified by the localpath argument. If you do not specify the argument, it downloads the file to the current working directory.

So you want this:

sftp.get('directory/file.csv', '/local/path/file.csv')

If you really want to read the file to a variable (what I understand that you actually do not want), you need to use Connection.getfo, like:

flo = BytesIO()
sftp.getfo(remotepath, flo)

Alternatively, use Paramiko library directly (without the pysftp wrapper).
See Read a file from server with SSH using Python.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!