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)