如何解决我收到错误“NoneType”对象在第 11 行中没有属性“文件大小”
我写了下面的代码。我明白了我在标题中写的问题。当我将 progressive= True
放在第 6 行时会发生这种情况。我是 Python 编程的新手,因此不胜感激
if file_format == "mp4" or file_format == "video":
resolution_ = str(input("Enter Resolution: ") + "p")
yt = YouTube(link,on_progress_callback=progress_Check)
yt.register_on_progress_callback(progress_Check)
video = yt.streams.filter(progressive= True,file_extension= file_format,resolution= resolution_).first()
title = yt.title
print ("Getting Video: ",title)
global file_size
file_size = video.filesize
print ("File size is: ",file_size)
video.download(path)
回溯(最近一次调用最后一次): 文件“C:\Users\infin\AppData\Local\Programs\Python\Python39\lib\runpy.py”,第 197 行,在 _run_module_as_main 返回_run_code(代码,main_globals,无, 文件“C:\Users\infin\AppData\Local\Programs\Python\Python39\lib\runpy.py”,第 87 行,run_code exec(代码,run_globals) 文件“c:\Users\infin.vscode\extensions\ms-python.python-2020.11.371526539\pythonFiles\lib\python\debugpy_main.py”,第 45 行,在 cli.main() 文件“c:\Users\infin.vscode\extensions\ms-python.python-2020.11.371526539\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py”,第 430 行,在 main 跑步() 文件“c:\Users\infin.vscode\extensions\ms-python.python-2020.11.371526539\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py”,第 267 行,在 run_file 中 文件“C:\Users\infin\AppData\Local\Programs\Python\Python39\lib\runpy.py”,第 268 行,在 run_path 中 返回 _run_module_code(code,init_globals,run_name,文件“C:\Users\infin\AppData\Local\Programs\Python\Python39\lib\runpy.py”,第 97 行,_run_module_code _run_code(代码,mod_globals,init_globals, 文件“C:\Users\infin\AppData\Local\Programs\Python\Python39\lib\runpy.py”,第 87 行,在 _run_code 中 exec(代码,run_globals) 文件“d:\Python\YouTube_Downloader\project.py”,第 43 行,在 file_size = video.filesize AttributeError: 'NoneType' 对象没有属性 'filesize'
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。