当我试图生成大小100个或更多的随机字符串,它给了我异常...生成大小为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的随机字符串? 以及为什么这个例外?
取决于比'100'你想去的地方...... – jamylak