-1

我尝试使用以下代码创建一个进度条来查看文件传输的进度。

from tqdm import tqdm
import pysftp
cnopts = pysftp.CnOpts()
cnopts.hostkeys = None
srv = pysftp.Connection(host=host,username=username,password=password,cnopts=cnopts)
with tqdm(unit = 'blocks', unit_scale = True, leave = False, miniters = 1, desc = 'Uploading......', total = filesize) as tqdm_instance:
    srv.put("D:\\wp-deploy.jpg","/var/www/html/wp-deploy.jpg",callback=lambda sent:tqdm_instance.update(len(sent)))

我得到了这个错误:

TypeError: <lambda>() takes 1 positional argument but 2 were given
4

1 回答 1

2

文档

  • callback ( callable ) -- 可选的回调函数 (form: func(int, int)),它接受到目前为止传输的字节数和要传输的总字节数
于 2017-09-16T15:48:23.427 回答