py ftp

from ftplib import FTP

# 连接到FTP服务器
ftp = FTP('10.129.250.27')
ftp.login(user='用户名', passwd='密码')

# 列出FTP服务器上的文件和目录
ftp.retrlines('LIST')

# 下载文件
filename = 'robots.txt'
with open(filename, 'wb') as file:
    ftp.retrbinary('RETR ' + filename, file.write)

# 上传文件
filename = 'robots.txt'
with open(filename, 'rb') as file:
    ftp.storbinary('STOR ' + filename, file)

# 断开FTP连接
ftp.quit()

 

posted @ 2024-05-05 19:37  shiningrise  阅读(11)  评论(0编辑  收藏  举报
// 侧边栏目录 // https://blog-static.cnblogs.com/files/douzujun/marvin.nav.my1502.css