ctypes - numpy array with no shape?
问题 I am using a python wrapper to call functions of a c++ dll library. A ctype is returned by the dll library, which I convert to numpy array score = np.ctypeslib.as_array(score,1) however, the array has no shape? score >>> array(-0.019486344729027664) score.shape >>> () score[0] >>> IndexError: too many indices for array How can I extract a double from the score array? Thank you. 回答1: You can access the data inside a 0-dimensional array via indexing [()] . For example, score[()] will retrieve