【发布时间】:2019-04-12 15:11:50
【问题描述】:
有人知道有没有等价的
import random
random.choices(population, weitghts, k=1)
.. 为Python Mode for Processing?。
我想为this StackOverflow 问题部署算法,但找不到所需的函数。
【问题讨论】:
标签: python processing
有人知道有没有等价的
import random
random.choices(population, weitghts, k=1)
.. 为Python Mode for Processing?。
我想为this StackOverflow 问题部署算法,但找不到所需的函数。
【问题讨论】:
标签: python processing
处理is built on Jython, and Jython still hasn't crawled out of the Python 2 era 的 Python 模式(它仅在 2015 年从 2.5 迁移到 Python 2.7 兼容性,2.7 发布五年后)。
random.choices was introduced in Python 3.6;即使处理的 Python 模式提供了对所有 Python 功能的完全访问权限(我很难确定它是否提供),Jython 的 2.7 兼容性意味着它在 Python 3.1 之后几乎没有引入任何功能,因此 random.choices 在不重新实现的情况下不可用从头开始。当然,random.choicesis open source and posted online 的代码,所以你总是可以自己向后移植到 Python 2(连同它所依赖的 itertools.accumulate)。
【讨论】: