Python tqdm TypeError: <lambda>() takes 1 positional argument but 2 were given
Python tqdm TypeError: <lambda>() takes 1 positional argument but 2 were given
我尝试使用以下代码创建一个进度条来查看文件传输的进度。
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
来自the docs:
- callback (callable) – optional callback function (form:
func(int, int)
) that accepts the bytes transferred so far and the total bytes to be transferred
我尝试使用以下代码创建一个进度条来查看文件传输的进度。
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
来自the docs:
- callback (callable) – optional callback function (form:
func(int, int)
) that accepts the bytes transferred so far and the total bytes to be transferred