ftplib上传和下载get stu

2024-04-30 04:31:27 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图通过Python的ftplib库将一个文件上传到我的VPS(由GoDaddy托管):

from ftplib import FTP
session = FTP('ftp.wangsibo.xyz','wsb','Wsb.139764')
file = open('source10.png','rb')
session.storbinary('store_source10.png', file)
file.close()
session.quit()

但是它在第4行卡住了(文件只有几个k,需要几分钟)。当我试图使用retrbinary进行阅读时,也会发生同样的情况。在

我试过用FileZilla,效果很好。有什么建议吗?在


Tags: 文件fromimportpngsessionvpsftpfile
1条回答
网友
1楼 · 发布于 2024-04-30 04:31:27

FTP.storbinary(command, fp[, blocksize, callback, rest])

Store a file in binary transfer mode. command should be an appropriate STOR command: "STOR filename". fp is an open file object which is read until EOF using its read() method in blocks of size blocksize to provide the data to be stored.

store_source10.png不是一个命令,可以尝试使用STOR source10.png。在

例如

from ftplib import FTP
session = FTP('ftp.wangsibo.xyz','wsb','Wsb.139764')

file=open('source10.png','rb')
session.storbinary('STOR source10.png',file)

file.close()
session.quit()

相关问题 更多 >