【发布时间】:2022-06-10 18:57:10
【问题描述】:
我在堆栈溢出时发现了这段代码,但我无法将它与 numpy 数组一起使用。谁能帮忙?
# Define how large to make the object.
size = 3
# Build the three dimensional list.
memory = []
for x in range(0,size):
memory.append([])
for y in range(0,size):
memory[x].append([])
for z in range(0,size):
memory[x][y].append(0) # Fill with zeros.
# Iterate through all values.
for x in range(0,size):
for y in range(0,size):
for z in range(0,size):
print 'memory[' + str(x) + '][' + str(y) + '][' + str(z) + ']=' + str(memory[x][y][z])
# Example access.
print 'Example access:'
print 'memory[0][1][2]=' + str(memory[0][1][2])
【问题讨论】:
-
“我无法使用它”是什么意思。它会出错吗?如果是这样,你能发布错误吗?