写一段python代码,生成一个UI来实现windows与linux文件交互。要求使用f t p
时间: 2023-02-23 18:09:38 浏览: 75
# 以下是 Python 代码:
import ftplib# 初始化ftp
ftp = ftplib.FTP()
ftp.set_pasv(True)# 连接到服务器
ftp.connect('hostname', 21)# 登录
ftp.login('username', 'password')# 从windows上传文件到linux
filename = 'windowsfile.txt'
ftp.storbinary('STOR ' + filename, open(filename, 'rb'))# 从linux下载文件到windows
filename = 'linuxfile.txt'
ftp.retrbinary('RETR ' + filename, open(filename, 'wb').write)# 关闭ftp连接
ftp.quit()