K12教育赛事综合服务平台
聚乐之家官方网站
下载聚乐之家官方App
专注青少年竞赛题库网站
已知如下代码片段:
import numpy as np arr = np.arange(6)
执行arr.reshape(2,3)会直接修改原数组arr的形状
arr.reshape(2,3)
arr
arr.reshape(3,2)返回的新数组与原数组arr共享底层内存(属于视图而非副本)
arr.reshape(3,2)
执行arr.reshape(3,3)可以正常运行,不会抛出异常
arr.reshape(3,3)
执行arr.reshape(2,-1)会因形状不匹配抛出ValueError异常
arr.reshape(2,-1)
ValueError