ftp in python 3.6

时间:2017-04-27 13:22:54

标签: python ftp ftplib

我想将一些数据从python传输到不需要登录的FTP服务器......从C ++我可以传输数据而不需要验证,这样Ftp服务器运行良好..我想在python中做同样的事情。 ..

ftp=ftplib.FTP('192.168.1.21')
filename= "test.html"
myfile = open('/Users/Univers/Desktop/test.html', 'rb')
ftp.storlines('STOR ' + filename, myfile)
ftp.quit()

这样的事情,但它让我回答:

ftplib.error_perm: 530 User cannot log in.

由于

1 个答案:

答案 0 :(得分:0)

我认为你需要:

from ftplib import FTP
ftp = FTP('127.0.0.1')     # connect to host, default port
ftp.login()                     # user anonymous, passwd anonymous@ default
ftp.retrlines('LIST')           # list directory contents
ftp.quit()

我在脚本中看不到ftp.login()。