我刚刚在Python 3.5中做了一些随机的事情.有15分钟的业余时间,我想出了这个:
a = {"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"}
len_a = len(a)
list = list(range(0, len_a))
message = ""
wordlist = [ch for ch in message]
len_wl = len(wordlist)
for x in list:
print (a[x])
Run Code Online (Sandbox Code Playgroud)
但令人满意的随机成功的感觉并没有超过我.相反,失败的感觉:
Traceback (most recent call last):
File "/Users/spathen/PycharmProjects/soapy/soup.py", line 9, in <module>
print (a[x])
TypeError: 'set' object does not support indexing
Run Code Online (Sandbox Code Playgroud)
请帮忙