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)
本文来自博客园,作者:OTAKU_nicole,转载请注明原文链接:https://www.cnblogs.com/nicole-zhang/p/16355589.html