6
如何访问数组中的字典?numpy数组中的字典?
import numpy as np
x = np.array({'x': 2, 'y': 5})
我最初的想法:
x['y']
Index Error: not a valid index
x[0]
Index Error: too many indices for array
如何访问数组中的字典?numpy数组中的字典?
import numpy as np
x = np.array({'x': 2, 'y': 5})
我最初的想法:
x['y']
Index Error: not a valid index
x[0]
Index Error: too many indices for array
如果添加方括号中数组赋值,你将有一个一维数组:
x = np.array([{'x': 2, 'y': 5}])
那么你可以使用:
x[0]['y']
我相信它会更有意义。
如此简单:P +1 – linusg
啊我看到完美的感谢! –