我如何编写一个函数来为我提供列表元素的随机索引,但基于列表中的概率?
该列表看起来像这样,有 5 个元素。
a = [0.1, 0.2, 0.4, 0.2, 0.1]
有没有简单快速的解决方案?谢谢
python
python ×1