0

我真的很难将一个简单的.txt文件上传到 FTP 服务器。我的桌面上有一个文件夹,其中包含两个文件:text.txtupload_to_ftp.py.

我试过这些:
FTP文件上传
Python脚本通过FTP上传文件
但似乎都不起作用。

我已经重写了很多次代码,我一直在努力,我不断收到错误,例如:

sftp = ftplib.FTP('REMOTEFTPSITE.com', 'MYUSERNAME', 'MYPASSWORD')
File "C:\Python27\lib\ftplib.py", line 117, in __init__
self.connect(host)
File "C:\Python27\lib\ftplib.py", line 135, in connect
self.welcome = self.getresp()
File "C:\Python27\lib\ftplib.py", line 210, in getresp
resp = self.getmultiline()
File "C:\Python27\lib\ftplib.py", line 196, in getmultiline
line = self.getline()
File "C:\Python27\lib\ftplib.py", line 183, in getline
line = self.file.readline()
File "C:\Python27\lib\socket.py", line 447, in readline
data = self._sock.recv(self._rbufsize)
error: [Errno 10054] An existing connection was forcibly closed by the remote host

任何帮助都会很棒!提前致谢。

4

1 回答 1

0

确保您确实在此行中提供了服务器、用户名和密码:

sftp = ftplib.FTP('REMOTEFTPSITE.com', 'MYUSERNAME', 'MYPASSWORD')
于 2013-02-07T18:07:28.370 回答