这里写自定义目录标题 判断一个变量是列表还是数组 判断一个变量是列表还是数组 import numpy as np type1 = ' ' a = [1,2,3,4,5] if isinstance(a,list): type1 = ' a is list' elif isinstance(a,np.ndarray): type1 = 'a is np.ndarray' else: type1 = 'other type!' print( 'type = ',type1 ) `` ## 输出结果 type = np.ndarray