FileNotFoundError:[Errno 2]没有这样的文件或目录:'/home/ubicomp/ubicomp/questions_check'。(将文件放入SFTP服务器。)

2024-09-30 09:24:19 发布

您现在位置:Python中文网/ 问答频道 /正文

我尝试使用以下代码将文件放入sftp服务器。我使用的是ubuntu 16.04。在

import pysftp as sftp

def sftp_file_transfer():
    s = sftp.Connection('ip_address', username='username', password='password')
    remote_path = '/var/sftp/uploads/'
    local_path = '/home/ubicomp/ubicomp/questions_check'
    s.put(local_path, remote_path)
    s.close()

我改变了现有的道路。但我得到了错误。我找不到问题。在

^{pr2}$

Tags: 文件path代码import服务器remoteubuntulocal
1条回答
网友
1楼 · 发布于 2024-09-30 09:24:19

我已经解决了这个问题。远程路径必须改变。它工作得很好。在

import pysftp as sftp

def sftp_file_transfer():
s = sftp.Connection('ip_address', username='username', password='password')
remote_path = '/uploads/questions_check.csv'
local_path = '/home/ubicomp/ubicomp/questions_check.csv'
s.put(local_path, remote_path)
s.close()

我不得不提到远程路径中具有相同扩展名的文件名,并取消了/var/sftp部分

相关问题 更多 >

    热门问题