【发布时间】:2020-10-03 06:06:57
【问题描述】:
我不知道该怎么做,每当我尝试其他主题的解决方案时,我都会遇到错误。 主要是“TypeError:show_progress_bar() 缺少 1 个必需的位置参数:'bytes_remaining'”。
from pytube import YouTube
#took this def from another topic
def progress_function(stream, chunk, file_handle, bytes_remaining):
percent = round((1-bytes_remaining/video.filesize)*100)
if( percent%10 == 0):
print(percent, 'done...')
url = "Any youtube url"
yt = YouTube(url, on_progress_callback=progress_function)
yt.streams[0].download()
例如,当我运行这个确切的代码时,它会给我那个错误。
我真的无法理解它的逻辑。我还搜索了 pytube3 网站上的文档,但我无法解决这个问题。请帮助我。谢谢。
【问题讨论】:
-
也许使用这样的东西:
def progress_test(*argv): print(argv)进行调试。 -
听起来它向您的函数传递了 3 个参数而不是 4 个,这将证明它向您的自定义进度函数传递了多少参数。
-
它给出了关于第四个参数“bytes_remaining”的错误
-
那你能去掉那个论点吗?
-
实际上是的,当我删除它时,其他参数打印没有错误。感谢这项技术。