Python:TypeError:float()参数必须是字符串或数字,而不是“function”

2024-03-29 09:48:55 发布

您现在位置:Python中文网/ 问答频道 /正文

我在JupyterWeb上工作,下面是我的代码。你知道吗

def get_hist(img, bins):
    histogram = np.zeros(bins)

    for pixel in im:
        histogram[pixel] += 1

    return get_hist

hist = get_hist(flat, 256)

plt.plot(hist)

我一直都有这个问题。你知道吗

TypeError: float() argument must be a string or a number, not 'function'

有什么有用的建议吗?你知道吗


Tags: 代码inimgforgetreturndefnp
1条回答
网友
1楼 · 发布于 2024-03-29 09:48:55

您编写了一个返回自己的函数对象的函数。这不会提供太多的功能或可用性。您可能需要返回histogram,这似乎是您的函数想要做的。你知道吗

相关问题 更多 >