首页
HTML/CSS
浏览器脚本
服务器脚本
数据库
应用编程
XML系列教程
建站手册
代码示例:(标识:demo_python_numpy_array_reshape_error)
运行代码
demo_python_numpy_array_reshape_error.py
import numpy as np arr = np.array([1, 2, 3, 4, 5, 6, 7, 8]) newarr = arr.reshape(3, 3) print(newarr)
运行结果:
<!DOCTYPE html><html><head><meta charset="utf-8"><title>Python Result</title><style>*{margin:0;padding:0}body{background:#000;color:#fff;line-height:1.5;font-family:consolas,"courier new",monospace}#python_result{padding:8px}</style></head><body><div id="python_result">C:\Users\My Name>python demo_python_numpy_array_reshape_error.py<br><pre>Traceback (most recent call last): File "demo_python_numpy_array_reshape_error.py", line 5, in <module> ValueError: cannot reshape array of size 8 into shape (3,3)</pre></div></body></html>