#多在编译器里尝试新操作 import numpy as np for i range(100): eval1 = {"A": ''"} eval2 = {"A": [[1], [2]]} if i%2 == 0: ar = np.array(eval1['A']) #此时打印ar,里面什么都没有 else: ar = np.array(eval2["A"]) #此时打印ar,是一个二维数组 if ar.shape == (): #不能
(Numpy中ndarray和array的区别是什么?我在哪儿能够找到numpy中相应的实现?) 答:Well, np.array is just a convenience function to create an ndarray, it is not a class itself. (嗯,np.array只是一个便捷的函数,用来创建一个ndarray,它本身不是一个类) You can also create an array using np.ndarray, but it is not