python删除1行20列的1矩阵前面的3列数值
时间: 2024-05-01 22:17:49 浏览: 70
您可以使用以下代码来删除1行20列的1矩阵前面的3列数值:
```
import numpy as np
# 创建1行20列的1矩阵
matrix = np.ones((1, 20))
# 删除前面的3列数值
matrix = matrix[:, 3:]
# 打印结果
print(matrix)
```
这将输出一个1行17列的矩阵,其中前面的3列数值已被删除。请注意,此代码是使用 NumPy 库实现的。
相关问题
python删除1行20列的0矩阵前面的3位数值
可以使用以下代码来实现:
```
import numpy as np
# 生成一个3x23的0矩阵
matrix = np.zeros((3, 23))
print(matrix)
# 删除第1行第20列的0
matrix = np.delete(matrix, 20, axis=1)
matrix = np.delete(matrix, 0, axis=0)
print(matrix)
```
这里使用了numpy库中的zeros函数生成一个3行23列的0矩阵,然后使用np.delete将第1行第20列的0删除,并将第一行删除。
阅读全文
相关推荐
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231044955.png)
![-](https://img-home.csdnimg.cn/images/20210720083327.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)