python - Python:TypeError:float() 参数必须是字符串或数字,而不是“函数”
问题描述
我在 Jupyter Web 上工作,下面是我的代码。
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'
有什么有用的建议吗?
解决方案
您编写了一个返回它自己的函数对象的函数。这不会提供太多功能或可用性。您可能需要 return histogram
,这似乎是您的功能打算做的事情。
推荐阅读
- php - 我想访问根目录外文件夹中的 index.php(nginx 窗口)
- python-3.x - 如何在熊猫中绘制此箱线图?
- javascript - 如何限制列表parant div的高度并使内容可滚动?
- pdf - mPDF 库问题:创建 pdf 后图像大小发生变化
- node.js - 如何使用nodejs从json文件中获取总值的平均值
- vue.js - 如何在 Vue js 中制作像小部件这样的未来构建器
- php-curl - PHP 通过 curl_exec 执行有 Ajax 请求不工作
- python - AttributeError:“按钮”对象没有属性
- javascript - 如何根据参数设置微光组件的初始状态?
- c++ - MinGw 无法从 cmake 编译测试文件