Couple of errors, you are missing a ]
on xyz[y, x, new[idx]] = new[idx]
. Put that back in and it should fix one error.
Also in python if you want to use try
, you need to have an except clause. If you don't want it, you can just have an empty pass
statement in there.
# pre-define
import numpy as np
import matplotlib.pyplot as plt
# from txt to array
file = ('..locationdata.TXT')
# 2D data in value
data2D = np.loadtxt(file, delimiter='')
# 1D data in array
data1D = digits.flatten()
# width / height
w = data2D.shape[0]
h = data2D.shape[1]
# try to convert to 3d array[X,Y,depth]
try:
for y in range(0, h):
for x in range(0, w):
idx = y * w + x
xyz[y, x, new[idx]] = new[idx]
except:
pass
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…