random_util

加权随机

from xlib.util import random_util

data = ['A', 'B', 'C', 'D']
print random_util.weight_choice(data, [10, 2, 2, 1])

Last updated