ValueError: Sample larger than population or is negative

import random
import string

tempId = ''.join(random.sample(string.digits, 11))
print(tempId)

报错:ValueError: Sample larger than population or is negative

因为11大于string.digits的长度,加大样本长度可解决

tempId = ''.join(random.sample(string.digits*2, 11))
print(tempId)

 

posted @ 2022-06-08 14:33  OTAKU_nicole  阅读(585)  评论(0编辑  收藏  举报