到目前为止,我一直在犯的所有“错误”都是我遗漏的小事,希望这里就是这种情况。我决定主要使用 NUMPY 数组来调整数组大小。我注意到导入需要一段时间,但它本质上是在做我需要的事情,所以乞丐不能成为选择者。无论如何,在尝试从数组中“删除”项目并通过“插入”用新数据替换它们时,我仍然有一个包含全零的数组。所以,我很茫然。我知道 [archstartred]、[archstartgrn] 和 [archstartblu] 的值是正确的,因为我会在它们生成时打印它们。为什么值没有填充到数组中?这是我的代码:
#Frame Creation
from numpy import *
frames=array([0 for i in range (0,workingframes*archnodes*3)])
frames.resize(archnodes*3, workingframes)
#Frame Population
for f in range (0, workingframes):
if f<=(workingframes/2):
for x in range (0, archnodes):
delete(frames,[x+f])
insert(frames,[x+f],(archstartred[x]))
print archstartred[x]
delete(frames,[x+f+workingframes])
insert(frames,[x+f+workingframes],(archstartgrn[x]))
print archstartgrn[x]
delete(frames,[x+f+workingframes*2])
insert(frames,[x+f+workingframes*2],(archstartblu[x]))
print archstartblu[x]
print frames
raw_input('Press control c') #stop/troubleshoot program
for y in range (0, nodesperframe):
archstartred.pop()
archstartgrn.pop()
archstartblu.pop()
archstartred.insert(0, backred)
archstartgrn.insert(0, backgrn)
archstartblu.insert(0, backblu)
archstartred = [int(value) for value in archstartred]
archstartgrn = [int(value) for value in archstartgrn]
archstartblu = [int(value) for value in archstartblu]
else:
for y in range (0, nodesperframe):
archstartred.pop(0)
archstartgrn.pop(0)
archstartblu.pop(0)
archstartred.append(backred)
archstartgrn.append(backgrn)
archstartblu.append(backblu)
archstartred = [int(value) for value in archstartred]
archstartgrn = [int(value) for value in archstartgrn]
archstartblu = [int(value) for value in archstartblu]
for x in range (0, archnodes):
delete(frames,[x+f])
insert(frames,[x+f],(archstartred[x]))
delete(frames,[x+f+workingframes])
insert(frames,[x+f+workingframes],(archstartgrn[x]))
delete(frames,[x+f+workingframes*2])
insert(frames,[x+f+workingframes*2],(archstartblu[x]))