【发布时间】:2021-04-10 05:58:20
【问题描述】:
我正在尝试从 Youtube Data API 获取我的 youtube 统计信息,然后将所有统计信息放在图像上。
当我尝试将参数传递给我的图像生成器函数时,
# vid_stats and c_stats are dictionaries,
# but in them, there's no "video_title" key or anything
statimager.create_image(video_title="Video title", video_stats=vid_stats, channel_stats=c_stats)
它给了我这个类型错误:
Traceback (most recent call last):
File "D:\_Prog\Python\ytstatupdater\ytstatupdater.py", line 118, in <module>
statimager.create_image(video_title="Video title", video_stats=vid_stats, channel_stats=c_stats)
TypeError: create_image() got multiple values for argument 'video_title'
这里是 create_image() 函数的定义:
def create_image(video_title, video_stats, channel_stats):
在这个函数中,我只使用这些参数将video_title,以及video_stats 和channel_stats 中的字符串放入一个字符串数组中。
我真的不明白为什么程序要传递多个值作为 video_title,因为 video_title 是单个字符串对象。
我正在使用 Python 3.9.1。
【问题讨论】:
-
video_title究竟包含什么?你能通过打印来验证它并向我们展示你得到了什么吗? -
create_image是statimager的静态方法还是statimager的实例方法? -
我认为你需要一个minimal reproducible example。仅凭这些部分很难了解问题的完整背景。
-
您是否忘记将
self作为create_image()方法的第一个参数? -
所有方法都需要有
self作为第一个参数,这似乎是方法create_image中缺少的
标签: python python-imaging-library youtube-data-api