首先,我是一个学习python的新手。我正在尝试使用python将文件上载/下载到服务器。服务器ftp没有域名,但有一个IP地址,即192.168.0.20和端口21我尝试了以下代码,但它给出了很多错误
import ftplib
#FTP server credentials
FTP_HOST = '192.16.0.20'
PORT='21'
FTP_USER = 'ftpuser'
FTP_PASS = 'ftpuser'
# connecting to the FTP server
ftp = ftplib.FTP(FTP_HOST,PORT, FTP_USER, FTP_PASS)
# force UTF-8 encoding
ftp.encoding = "utf-8"
# local file name you want to upload
filename = "test.txt"
with open(filename, "rb") as file:
# use FTP's STOR command to upload the file
ftp.storbinary(f'STOR {filename}', file)
# list current files & directories
ftp.dir()
# quit and close the connection
ftp.quit()帮助--我哪里错了?
发布于 2021-10-22 10:06:29
在创建FTP对象之后,您可能需要使用ftp.login()登录到服务器。
你得到了哪些确切的错误?
https://stackoverflow.com/questions/69674852
复制相似问题