【发布时间】:2018-02-08 09:35:21
【问题描述】:
我尝试将数组从列表转换为数组:事实上,我在 9 组 tempTracesHW [hw] hw=[0,9] 中有滑动轨迹然后我只想显示每个 temTracesHW 中的一个元素,所以我转换tempTracesHW[i] 变成这样的表:
tempTraces = np.load(r'E:\\blockData\\Concatenated_Traces.npy')
print (tempTraces.shape)
tempSbox = [inv_sbox[tempCText[i][0] ^ tempKey[i][0]] for i in range(len(tempCText))]
tempHW = [hw[s] for s in tempSbox]
tempTracesHW = [[] for _ in range(9)]
print tempTracesHW
# Fill them up
for i in range(len(tempTraces)):
HW = tempHW[i]
tempTracesHW[HW].append(tempTraces[i])
# Switch to numpy arrays
tempTracesHW = [np.array(tempTracesHW[HW]) for HW in range(9)]
print(tempTracesHW)
for i in range(HW):
print('hw=',i)
print(len(tempTracesHW[i]))
print(tempTracesHW[i])
Tab= np.asarray(tempTracesHW[i])
print(Tab.shape)
for k in len(Tab):
print(Tab[k])
但它给了我这个错误:
for k in len(Tab):
TypeError: 'int' object is not iterable
【问题讨论】:
-
你需要从
len返回的int创建一个iterable:for k in range(len(Tab)),prolly。
标签: python arrays for-loop iteration typeerror