python 三维数组 w4[:, 1] 取值
Posted gz153016
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 三维数组 w4[:, 1] 取值相关的知识,希望对你有一定的参考价值。
import numpy as np
a = [1, 2, 3] ; b = [4, 5, 6]; c = [7, 8, 9] ; d = [10,11,12]
# 每一页 / 每一个二维数组内容不同:
w3 = np.array( [ [a,b], [a,c], [b,c], [a,d] ] )
w4 = np.array( [ [a,b,d], [a,c,d], [b,c,d],[a,a,d]] )
print('w3:\\n', w3.shape) # (4, 2, 3)
print('w4:\\n', w4.shape) # (4, 3, 3)
print('w3[:, 1]:\\n', w3[:, 1].shape) # (4, 3)
print('w4[:, 1]:\\n', w4[:, 0].shape) # (4, 3)
print('w3:\\n', w3)
print('w3[:, 0]:\\n', w3[:, 0])
print('w4:\\n', w4)
print('w4[:, 1]:\\n', w4[:, 1])
w3:
[
[[ 1 2 3]
[ 4 5 6]]
[[ 1 2 3]
[ 7 8 9]]
[[ 4 5 6]
[ 7 8 9]]
[[ 1 2 3]
[10 11 12]]
]
w3[:, 0]:
[[1 2 3]
[1 2 3]
[4 5 6]
[1 2 3]]
w4:
[[[ 1 2 3]
[ 4 5 6]
[10 11 12]]
[[ 1 2 3]
[ 7 8 9]
[10 11 12]]
[[ 4 5 6]
[ 7 8 9]
[10 11 12]]
[[ 1 2 3]
[ 1 2 3]
[10 11 12]]]
w4[:, 1]:
[[4 5 6]
[7 8 9]
[7 8 9]
[1 2 3]]
以上是关于python 三维数组 w4[:, 1] 取值的主要内容,如果未能解决你的问题,请参考以下文章