擅长:python、mysql、java
<p>首先,您需要<a href="https://docs.python.org/2/library/random.html" rel="nofollow noreferrer">random module</a>:</p>
<pre><code>import random
</code></pre>
<p>然后我会用这个方法:</p>
<pre><code>your_list = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q',
'r','s','t','u','v','w','x','y','z','1','2','3','4','5','6','7','8','9',
'0'," ",'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P',
'Q','R','S','T','U','V','W','X','Y','Z']
first_26_characters = your_list[0:26] # get items from 0 to 26 in new list
random.shuffle(first_26_characters) # shuffle new list
random_8_characters = first_26_characters[0:8] # get first 8 characters because after shuffle they are random
</code></pre>
<p>我希望这有帮助!你知道吗</p>