在假設隨機抽樣,有一個corresponding sampled_from()
strategy到random.choice()
:與假說
In [1]: from hypothesis import find, strategies as st
In [2]: find(st.sampled_from(('ST', 'LT', 'TG', 'CT')), lambda x: True)
Out[2]: 'ST'
但是,有一種方法來有random.sample()
樣的策略,以產生長度爲N個子序列進行序列的?
In [3]: import random
In [4]: random.sample(('ST', 'LT', 'TG', 'CT'), 2)
Out[4]: ['CT', 'TG']
簡單得多,再次感謝! – alecxe