我想更改python时出错随机抽样数组索引。我想换我的随机抽样增加+1数组索引
x=0
randomarray = random.sample(range(1, len(codelist) - len(Genx1) - len(Genx2)), 3*len(s))
while (x < len(s)):
randomarray.sort()
print(randomarray)
if ((codelist[randomarray[x]]=='B' ) and (s[x]=='A') or (codelist[randomarray[x]]=='A' ) and (s[x]=='B')):
codelist[randomarray[x]] = s[x]
x = x + 1
else:
random[x]= random[x]+1
x = x
line 403, in ... random[x]= random[x]+1 TypeError: 'module' object is not subscriptable
random
是包含所有随机函数的模块的名称。您试图将其用作列表或数组:random[x]
不是一个有意义的表达式。而且,x = x
是一行无用的代码,它什么也不做。在相关问题 更多 >
编程相关推荐