在连接数组时,给出错误

时间:2015-03-16 07:35:21

标签: python numpy

代码:

import numpy as np;
import joblib

var=np.zeros((4, 4))
var1=np.zeros((4, 4))

va=np.concatenate(var,var1)

joblib.dump(va, '/media/ab/AB-3/file_name.dat')

aa=joblib.load('/media/ab/AB-3/file_name.dat',None)

print aa

错误:

Traceback (most recent call last):
  File "/home/ab/Pictures/store.py", line 6, in <module>
    va=np.concatenate(var,var1)
TypeError: only length-1 arrays can be converted to Python scalars

1 个答案:

答案 0 :(得分:1)

查看文档http://docs.scipy.org/doc/numpy/reference/generated/numpy.concatenate.html

va=np.concatenate((var,var1),axis=0)