當我試圖生成大小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