【发布时间】:2017-01-06 02:22:54
【问题描述】:
我在 Python 中使用genetic algorithm toolbox。代码:
toolbox.register("attr_bool", random.randint, 0, 1) 通常定义要生成的随机数0 和1。问题是我正在寻找 0 和 1 之间的随机数。我使用了toolbox.register("attr_bool", random.uniform(0, 1)),但它给我带来了以下错误:
TypeError: the first argument must be callable
【问题讨论】:
-
看第二个答案而不是第一个
-
看看你的括号。将它们与示例的括号进行比较。
标签: python random genetic-algorithm