from pytube import YouTube
video = YouTube('https://www.youtube.com/watch?v=tDKSwtKhteE')
print('Author: ' + video.author)
print('Title: ' + video.title)
print('Description: ' + video.description)
字符串
你好啊!
我正在尝试使用Python中的Pytube库从Youtube视频中获取视频描述。
当我试图获取描述时,我得到了这个错误
print('Description: ' + video.description)
~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
TypeError: can only concatenate str (not "NoneType") to str
型
Pytube给了我一个“无”,但是,为什么?
有什么想法吗?
谢谢
这个脚本在一年前就能用了,现在我有了Pytube v15。我读了Pytube文档,但没有发现任何新的东西https://pytube.io/en/latest/api.html#pytube.YouTube.description
1条答案
按热度按时间e0bqpujr1#
不幸的是,正如PyTube的this问题中所述,PyTube中存在一个bug,使其无法显示描述。唯一的方法是编写另一个函数来获取描述。根据此评论,该函数可以像这样实现:
字符串
把它放在一起:
型