我上传的FTPLib在Python中的文件,并有一个cli加载栏与progressbar 2.2. 我需要一个加载栏来告诉上传的进度。Python的FTP上传栏
有没有人有任何有关该主题的信息?
感谢,giodamelio
由于塞特希库马兰指出的那样,在ftplib.storbinary功能的回调参数,但我不知道如何使用它。
我试过了。每次上传一个字节,我都希望它能打印这条消息。
import ftplib
def callback():
print("This is the callback function")
s = ftplib.FTP('myserver.com','login','password') # Connect
f = open('test.txt','rb') # file to send
s.storbinary('STOR test.txt', f, 1024, callback()) # Send the file
f.close() # Close file and FTP
s.quit()
不要调用你的回调函数 - 你实际上是在传入None作为回调函数。 – JimB 2011-04-15 18:42:45
我从来没有使用回调函数,所以我有点困惑。我应该改变哪一部分? – giodamelio 2011-04-15 18:46:26