python数据类型--numpy、list、tuple

numpy   数组(np.numpy),有shape、size、num等许多属性

list         列表,append、copy等属性,列表使用方括号

tuple      元祖,没有shape、size等,元组与列表类似,不同处在于元组不能修改,元组使用圆括号

a = ([1,2],[3,4],[5,6])    #<class 'tuple'>
a = [[1,2],[3,4],[5,6]]    #list--列表
b = np.array(a)            #<class 'numpy.ndarray'>
c = b.tolist()             #转换成list ,<class 'list'>
print (len(a[0]))    #行数
print (len(a[1]))    #列数
print (type(a))
print (b.shape)

猜你喜欢

转载自blog.csdn.net/qq_34638161/article/details/80889159