如何删除python列表框架

如何删除python列表框架,python,Python,像这样,假设我有一个这样的脚本: a = ['a','b','c','d','e'] b = random.choices(a) print (b) import random a = ['a','b','c','d','e'] n = random.randint(0, len(a) - 1) # The randint() takes in 2 parameters, the #lowest and the highest choice, the highest here is the

像这样,假设我有一个这样的脚本:

a = ['a','b','c','d','e']
b = random.choices(a)
print (b)
import random
a = ['a','b','c','d','e']
n = random.randint(0, len(a) - 1) # The randint() takes in 2 parameters, the 
#lowest and the highest choice, the highest here is the length of a list
b = a[n]
print(b)
如果你运行它,它会像这样显示,对吗

['*random range a until e']
我希望列表从
['*随机范围a到e']
更改为
'*随机范围a到我们'
任何人都可以帮助我random.choices(),返回一个列表,如您在此处所读-

所以解决办法是这样做:

a = ['a','b','c','d','e']
b = random.choices(a)
print (b)
import random
a = ['a','b','c','d','e']
n = random.randint(0, len(a) - 1) # The randint() takes in 2 parameters, the 
#lowest and the highest choice, the highest here is the length of a list
b = a[n]
print(b)

您需要加入从中获得的字母

使用参数
k=
可以指定生成字符串的长度

>>随机导入
>>>a=['a','b','c','d','e']
>>>尺寸=10
>>>b=“”.连接(随机选择(a,k=大小))
>>>b
“卡卡巴德”