当我上传.gz文件时,ftplib库出现问题。在
这个脚本以前是有效的,但不知何故,在我数千个版本中的一个版本中,我更改了导致传输损坏文件的某些内容。
文件已成功传输到ftp服务器,但是,在ftp中使用的文件不会打开,因为已损坏。在
要传送的文件没有任何问题。另外,如果文件没有压缩,传输也没有任何问题。它和它的阅读方式有关
有谁能告诉我密码有什么问题吗?在for filename in dir:
os.system("gzip %s/%s" % (Path, filename))
time.sleep(5) # Wait up to 4 seconds to compress file
zip_filename = filename + '.gz'
try:
# Connect to the host
ftp = ftplib.FTP(host)
# Login to the ftp server
ftp.login(username, password)
# Transfer the file
myfile = open(zip_filename, 'rb')
ftp.storlines("STOR temp/" + zip_filename, myfile)
myfile.close()
except ftplib.all_errors as e:
print(e)