当我试图生成大小为 100 或更大的随机字符串时,它给了我例外......
msg="".join(random.sample(string.letters+string.digits,random.randint(5,100)))
Exception:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/random.py", line 316, in sample
raise ValueError, "sample larger than population"
ValueError: sample larger than population
您能帮我解释一下如何生成大小超过 100 的随机字符串吗?还有为什么这个例外?