{"id":958471,"date":"2024-12-27T03:28:34","date_gmt":"2024-12-26T19:28:34","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/958471.html"},"modified":"2024-12-27T03:28:37","modified_gmt":"2024-12-26T19:28:37","slug":"python%e5%a6%82%e4%bd%95%e5%88%9b%e5%bb%bandarray%e6%95%b0%e7%bb%84","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/958471.html","title":{"rendered":"python\u5982\u4f55\u521b\u5efandarray\u6570\u7ec4"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25101522\/02983b0d-b5c6-49f8-9bb1-f32ea2f1c8f0.webp\" alt=\"python\u5982\u4f55\u521b\u5efandarray\u6570\u7ec4\" \/><\/p>\n<p><p> <strong>\u5728Python\u4e2d\u521b\u5efandarray\u6570\u7ec4\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528NumPy\u5e93\u5b9e\u73b0\uff0c\u65b9\u6cd5\u5305\u62ec\uff1a\u4f7f\u7528<code>array()<\/code>\u51fd\u6570\u4ece\u5217\u8868\u6216\u5143\u7ec4\u521b\u5efa\u3001\u4f7f\u7528\u5185\u7f6e\u51fd\u6570\u5982<code>zeros()<\/code>\u6216<code>ones()<\/code>\u521b\u5efa\u7279\u5b9a\u5f62\u72b6\u548c\u7c7b\u578b\u7684\u6570\u7ec4\u3001\u4ee5\u53ca\u5229\u7528<code>arange()<\/code>\u6216<code>linspace()<\/code>\u751f\u6210\u6570\u503c\u5e8f\u5217\u3002<\/strong> \u5176\u4e2d\uff0c\u4f7f\u7528<code>array()<\/code>\u51fd\u6570\u662f\u6700\u5e38\u89c1\u7684\u65b9\u6cd5\uff0c\u56e0\u4e3a\u5b83\u7b80\u5355\u76f4\u89c2\uff0c\u53ef\u4ee5\u76f4\u63a5\u4ece\u73b0\u6709\u7684Python\u6570\u636e\u7ed3\u6784\u521b\u5efandarray\u3002\u901a\u8fc7<code>zeros()<\/code>\u548c<code>ones()<\/code>\u51fd\u6570\uff0c\u60a8\u53ef\u4ee5\u5feb\u901f\u521b\u5efa\u7279\u5b9a\u5927\u5c0f\u548c\u521d\u59cb\u5316\u503c\u4e3a\u96f6\u6216\u4e00\u7684\u6570\u7ec4\uff0c\u9002\u7528\u4e8e\u9700\u8981\u521d\u59cb\u5316\u7279\u5b9a\u7ed3\u6784\u7684\u573a\u666f\u3002<code>arange()<\/code>\u548c<code>linspace()<\/code>\u5219\u9002\u5408\u7528\u4e8e\u751f\u6210\u89c4\u5219\u7684\u6570\u503c\u5e8f\u5217\uff0c\u975e\u5e38\u9002\u5408\u6570\u503c\u8ba1\u7b97\u6216\u751f\u6210\u7279\u5b9a\u8303\u56f4\u7684\u6570\u7ec4\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u4f7f\u7528<code>array()<\/code>\u51fd\u6570\u521b\u5efandarray<\/h3>\n<\/p>\n<p><p>NumPy\u5e93\u662fPython\u4e2d\u5904\u7406\u6570\u7ec4\u548c\u77e9\u9635\u7684\u5f3a\u5927\u5de5\u5177\u3002\u8981\u4f7f\u7528NumPy\uff0c\u9996\u5148\u9700\u8981\u786e\u4fdd\u5df2\u5b89\u88c5\u8be5\u5e93\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install numpy<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u4f7f\u7528<code>array()<\/code>\u51fd\u6570\u4ece\u5217\u8868\u6216\u5143\u7ec4\u521b\u5efa\u4e00\u4e2andarray\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<h2><strong>\u4ece\u5217\u8868\u521b\u5efandarray<\/strong><\/h2>\n<p>list_data = [1, 2, 3, 4, 5]<\/p>\n<p>array_from_list = np.array(list_data)<\/p>\n<p>print(&quot;Array from list:&quot;, array_from_list)<\/p>\n<h2><strong>\u4ece\u5143\u7ec4\u521b\u5efandarray<\/strong><\/h2>\n<p>tuple_data = (6, 7, 8, 9, 10)<\/p>\n<p>array_from_tuple = np.array(tuple_data)<\/p>\n<p>print(&quot;Array from tuple:&quot;, array_from_tuple)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4f7f\u7528<code>array()<\/code>\u51fd\u6570\uff0c\u60a8\u53ef\u4ee5\u4ece\u4efb\u4f55\u5e8f\u5217\u7c7b\u578b\uff08\u5982\u5217\u8868\u3001\u5143\u7ec4\uff09\u521b\u5efaNumPy\u6570\u7ec4\u3002\u8fd9\u79cd\u65b9\u6cd5\u7b80\u5355\u76f4\u89c2\uff0c\u662f\u521d\u5b66\u8005\u6700\u5e38\u7528\u7684\u521b\u5efandarray\u7684\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u4f7f\u7528<code>zeros()<\/code>\u548c<code>ones()<\/code>\u51fd\u6570\u521b\u5efandarray<\/h3>\n<\/p>\n<p><p>NumPy\u63d0\u4f9b\u4e86\u4e00\u4e9b\u4fbf\u6377\u7684\u51fd\u6570\uff0c\u53ef\u4ee5\u5feb\u901f\u521b\u5efa\u7279\u5b9a\u5f62\u72b6\u548c\u7c7b\u578b\u7684\u6570\u7ec4\uff0c\u4f8b\u5982<code>zeros()<\/code>\u548c<code>ones()<\/code>\u51fd\u6570\u3002\u5b83\u4eec\u5206\u522b\u7528\u4e8e\u521b\u5efa\u5143\u7d20\u5168\u90e8\u4e3a\u96f6\u6216\u4e00\u7684\u6570\u7ec4\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u521b\u5efa\u4e00\u4e2a3x3\u7684\u5168\u96f6\u6570\u7ec4<\/p>\n<p>zero_array = np.zeros((3, 3))<\/p>\n<p>print(&quot;Zero array:\\n&quot;, zero_array)<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2a2x4\u7684\u5168\u4e00\u6570\u7ec4<\/strong><\/h2>\n<p>one_array = np.ones((2, 4))<\/p>\n<p>print(&quot;One array:\\n&quot;, one_array)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong><code>zeros()<\/code>\u548c<code>ones()<\/code>\u51fd\u6570\u53ef\u4ee5\u6307\u5b9a\u6570\u7ec4\u7684\u5f62\u72b6\u548c\u6570\u636e\u7c7b\u578b<\/strong>\uff0c\u8fd9\u5728\u521d\u59cb\u5316\u9700\u8981\u56fa\u5b9a\u683c\u5f0f\u7684\u6570\u7ec4\u65f6\u7279\u522b\u6709\u7528\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7\u4f20\u9012\u5f62\u72b6\u5143\u7ec4\u6765\u6307\u5b9a\u6570\u7ec4\u7684\u5f62\u72b6\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u4f7f\u7528<code>arange()<\/code>\u548c<code>linspace()<\/code>\u751f\u6210\u6570\u503c\u5e8f\u5217<\/h3>\n<\/p>\n<p><p><code>arange()<\/code>\u548c<code>linspace()<\/code>\u51fd\u6570\u7528\u4e8e\u751f\u6210\u6570\u503c\u5e8f\u5217\uff0c\u9002\u5408\u6570\u503c\u8ba1\u7b97\u6216\u751f\u6210\u7279\u5b9a\u8303\u56f4\u7684\u6570\u7ec4\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u4f7f\u7528arange()\u751f\u6210\u4e00\u4e2a\u8303\u56f4\u6570\u7ec4<\/p>\n<p>range_array = np.arange(0, 10, 2)<\/p>\n<p>print(&quot;Range array:&quot;, range_array)<\/p>\n<h2><strong>\u4f7f\u7528linspace()\u751f\u6210\u4e00\u4e2a\u7ebf\u6027\u7b49\u95f4\u9694\u6570\u7ec4<\/strong><\/h2>\n<p>linspace_array = np.linspace(0, 1, 5)<\/p>\n<p>print(&quot;Linspace array:&quot;, linspace_array)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong><code>arange()<\/code>\u51fd\u6570\u7c7b\u4f3c\u4e8ePython\u7684\u5185\u7f6e<code>range()<\/code>\u51fd\u6570\uff0c\u4f46\u8fd4\u56de\u7684\u662fndarray<\/strong>\u3002\u5b83\u63a5\u53d7start\u3001stop\u548cstep\u53c2\u6570\u3002<code>linspace()<\/code>\u7528\u4e8e\u751f\u6210\u6307\u5b9a\u8303\u56f4\u5185\u7684\u7b49\u95f4\u9694\u6570\u503c\uff0c\u5e38\u7528\u4e8e\u751f\u6210\u7ed8\u56fe\u7684\u5750\u6807\u8f74\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u4f7f\u7528<code>random<\/code>\u6a21\u5757\u521b\u5efa\u968f\u673a\u6570\u7ec4<\/h3>\n<\/p>\n<p><p>NumPy\u7684<code>random<\/code>\u6a21\u5757\u63d0\u4f9b\u4e86\u521b\u5efa\u968f\u673a\u6570\u7ec4\u7684\u529f\u80fd\uff0c\u5e38\u7528\u4e8e\u6a21\u62df\u548c\u6570\u636e\u5206\u6790\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u521b\u5efa\u4e00\u4e2a3x3\u7684\u968f\u673a\u6570\u7ec4<\/p>\n<p>random_array = np.random.random((3, 3))<\/p>\n<p>print(&quot;Random array:\\n&quot;, random_array)<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2a3x3\u7684\u968f\u673a\u6574\u6570\u6570\u7ec4<\/strong><\/h2>\n<p>random_int_array = np.random.randint(0, 10, (3, 3))<\/p>\n<p>print(&quot;Random integer array:\\n&quot;, random_int_array)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong><code>random()<\/code>\u51fd\u6570\u751f\u62100\u52301\u4e4b\u95f4\u7684\u6d6e\u70b9\u6570<\/strong>\uff0c\u800c<code>randint()<\/code>\u51fd\u6570\u5219\u751f\u6210\u6307\u5b9a\u8303\u56f4\u5185\u7684\u968f\u673a\u6574\u6570\u3002\u968f\u673a\u6570\u7ec4\u5e38\u7528\u4e8e\u9700\u8981\u6a21\u62df\u968f\u673a\u73b0\u8c61\u6216\u751f\u6210\u6d4b\u8bd5\u6570\u636e\u7684\u573a\u666f\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001\u4f7f\u7528<code>full()<\/code>\u548c<code>eye()<\/code>\u51fd\u6570\u521b\u5efa\u7279\u5b9a\u6570\u7ec4<\/h3>\n<\/p>\n<p><p>NumPy\u8fd8\u63d0\u4f9b\u4e86\u4e00\u4e9b\u51fd\u6570\u7528\u4e8e\u521b\u5efa\u7279\u5b9a\u7c7b\u578b\u7684\u6570\u7ec4\uff0c\u5982<code>full()<\/code>\u548c<code>eye()<\/code>\u51fd\u6570\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u521b\u5efa\u4e00\u4e2a3x3\u7684\u5168\u6307\u5b9a\u503c\u6570\u7ec4<\/p>\n<p>full_array = np.full((3, 3), 7)<\/p>\n<p>print(&quot;Full array:\\n&quot;, full_array)<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2a3x3\u7684\u5355\u4f4d\u77e9\u9635<\/strong><\/h2>\n<p>identity_matrix = np.eye(3)<\/p>\n<p>print(&quot;Identity matrix:\\n&quot;, identity_matrix)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong><code>full()<\/code>\u51fd\u6570\u521b\u5efa\u4e00\u4e2a\u6307\u5b9a\u503c\u586b\u5145\u7684\u6570\u7ec4<\/strong>\uff0c\u800c<code>eye()<\/code>\u51fd\u6570\u7528\u4e8e\u521b\u5efa\u5355\u4f4d\u77e9\u9635\u3002\u5355\u4f4d\u77e9\u9635\u5728\u7ebf\u6027\u4ee3\u6570\u4e2d\u5e94\u7528\u5e7f\u6cdb\uff0c\u662f\u77e9\u9635\u4e58\u6cd5\u7684\u5355\u4f4d\u5143\u3002<\/p>\n<\/p>\n<p><h3>\u516d\u3001\u901a\u8fc7\u4ece\u6587\u4ef6\u52a0\u8f7d\u6570\u636e\u521b\u5efandarray<\/h3>\n<\/p>\n<p><p>NumPy\u53ef\u4ee5\u901a\u8fc7\u4ece\u6587\u4ef6\u52a0\u8f7d\u6570\u636e\u6765\u521b\u5efa\u6570\u7ec4\uff0c\u8fd9\u5bf9\u4e8e\u5904\u7406\u5927\u89c4\u6a21\u6570\u636e\u96c6\u975e\u5e38\u6709\u7528\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u5047\u8bbe\u6709\u4e00\u4e2a\u6587\u672c\u6587\u4ef6data.txt\uff0c\u5176\u4e2d\u5305\u542b\u4ee5\u4e0b\u6570\u636e\uff1a<\/p>\n<h2><strong>1, 2, 3<\/strong><\/h2>\n<h2><strong>4, 5, 6<\/strong><\/h2>\n<h2><strong>7, 8, 9<\/strong><\/h2>\n<h2><strong>\u4f7f\u7528loadtxt()\u51fd\u6570\u4ece\u6587\u4ef6\u52a0\u8f7d\u6570\u636e<\/strong><\/h2>\n<p>data_array = np.loadtxt(&#39;data.txt&#39;, delimiter=&#39;,&#39;)<\/p>\n<p>print(&quot;Data array:\\n&quot;, data_array)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong><code>loadtxt()<\/code>\u51fd\u6570\u7528\u4e8e\u4ece\u6587\u672c\u6587\u4ef6\u4e2d\u52a0\u8f7d\u6570\u636e<\/strong>\uff0c\u53ef\u4ee5\u6307\u5b9a\u5206\u9694\u7b26\u4ee5\u6b63\u786e\u89e3\u6790\u6570\u636e\u3002\u8fd9\u5bf9\u4e8e\u6570\u636e\u9884\u5904\u7406\u548c\u5206\u6790\u975e\u5e38\u6709\u7528\uff0c\u5c24\u5176\u662f\u5728\u5904\u7406CSV\u6587\u4ef6\u65f6\u3002<\/p>\n<\/p>\n<p><h3>\u4e03\u3001\u901a\u8fc7\u91cd\u5851\u548c\u6269\u5c55\u73b0\u6709\u6570\u7ec4\u521b\u5efa\u65b0\u7684ndarray<\/h3>\n<\/p>\n<p><p>\u5728NumPy\u4e2d\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u91cd\u5851\u548c\u6269\u5c55\u73b0\u6709\u6570\u7ec4\u6765\u521b\u5efa\u65b0\u7684\u6570\u7ec4\u7ed3\u6784\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u521b\u5efa\u4e00\u4e2a\u4e00\u7ef4\u6570\u7ec4<\/p>\n<p>original_array = np.array([1, 2, 3, 4, 5, 6])<\/p>\n<h2><strong>\u91cd\u5851\u4e3a2x3\u7684\u4e8c\u7ef4\u6570\u7ec4<\/strong><\/h2>\n<p>reshaped_array = original_array.reshape((2, 3))<\/p>\n<p>print(&quot;Reshaped array:\\n&quot;, reshaped_array)<\/p>\n<h2><strong>\u6269\u5c55\u6570\u7ec4\u4ee5\u589e\u52a0\u7ef4\u5ea6<\/strong><\/h2>\n<p>expanded_array = np.expand_dims(original_array, axis=0)<\/p>\n<p>print(&quot;Expanded array:\\n&quot;, expanded_array)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong><code>reshape()<\/code>\u51fd\u6570\u7528\u4e8e\u6539\u53d8\u6570\u7ec4\u7684\u5f62\u72b6<\/strong>\uff0c\u800c<code>expand_dims()<\/code>\u7528\u4e8e\u589e\u52a0\u6570\u7ec4\u7684\u7ef4\u5ea6\u3002\u8fd9\u4e9b\u529f\u80fd\u5728\u9700\u8981\u8c03\u6574\u6570\u636e\u7ed3\u6784\u4ee5\u9002\u5e94\u4e0d\u540c\u7b97\u6cd5\u548c\u6a21\u578b\u65f6\u975e\u5e38\u6709\u7528\u3002<\/p>\n<\/p>\n<p><h3>\u516b\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u5728Python\u4e2d\uff0c\u521b\u5efandarray\u6570\u7ec4\u7684\u65b9\u6cd5\u591a\u79cd\u591a\u6837\uff0c\u53d6\u51b3\u4e8e\u5177\u4f53\u9700\u6c42\u548c\u6570\u636e\u7ed3\u6784\u3002\u4f7f\u7528NumPy\u5e93\uff0c\u60a8\u53ef\u4ee5\u4ece\u57fa\u672c\u7684\u5217\u8868\u548c\u5143\u7ec4\u521b\u5efa\u6570\u7ec4\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7\u7279\u5b9a\u51fd\u6570\u521b\u5efa\u521d\u59cb\u5316\u6216\u968f\u673a\u586b\u5145\u7684\u6570\u7ec4\u3002\u6b64\u5916\uff0c\u901a\u8fc7\u4ece\u6587\u4ef6\u52a0\u8f7d\u6570\u636e\u548c\u8c03\u6574\u6570\u7ec4\u5f62\u72b6\uff0c\u60a8\u53ef\u4ee5\u7075\u6d3b\u5730\u5904\u7406\u5404\u79cd\u6570\u636e\u683c\u5f0f\u548c\u5e94\u7528\u573a\u666f\u3002\u638c\u63e1\u8fd9\u4e9b\u65b9\u6cd5\u5c06\u6781\u5927\u5730\u63d0\u9ad8\u60a8\u5728\u6570\u636e\u5206\u6790\u3001\u79d1\u5b66\u8ba1\u7b97\u548c<a href=\"https:\/\/docs.pingcode.com\/ask\/59192.html\" target=\"_blank\">\u673a\u5668\u5b66\u4e60<\/a>\u4e2d\u7684\u6548\u7387\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u521b\u5efa\u4e00\u4e2andarray\u6570\u7ec4\uff1f<\/strong><br \/>\u8981\u5728Python\u4e2d\u521b\u5efandarray\u6570\u7ec4\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528NumPy\u5e93\u3002\u9996\u5148\uff0c\u786e\u4fdd\u60a8\u5df2\u7ecf\u5b89\u88c5\u4e86NumPy\u3002\u53ef\u4ee5\u4f7f\u7528<code>pip install numpy<\/code>\u547d\u4ee4\u8fdb\u884c\u5b89\u88c5\u3002\u521b\u5efandarray\u6570\u7ec4\u7684\u5e38\u7528\u65b9\u6cd5\u5305\u62ec<code>numpy.array()<\/code>\u3001<code>numpy.zeros()<\/code>\u3001<code>numpy.ones()<\/code>\u548c<code>numpy.arange()<\/code>\u3002\u4f8b\u5982\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528<code>numpy.array([1, 2, 3])<\/code>\u6765\u521b\u5efa\u4e00\u4e2a\u5305\u542b\u6574\u6570\u7684\u6570\u7ec4\u3002<\/p>\n<p><strong>ndarray\u6570\u7ec4\u4e0ePython\u5217\u8868\u7684\u533a\u522b\u662f\u4ec0\u4e48\uff1f<\/strong><br \/>ndarray\u6570\u7ec4\u4e0ePython\u5217\u8868\u76f8\u6bd4\uff0c\u5177\u6709\u66f4\u9ad8\u7684\u6027\u80fd\u548c\u66f4\u5f3a\u7684\u529f\u80fd\u3002ndarray\u6570\u7ec4\u63d0\u4f9b\u4e86\u66f4\u5feb\u7684\u8fd0\u7b97\u901f\u5ea6\uff0c\u5c24\u5176\u662f\u5728\u5927\u6570\u636e\u96c6\u4e0a\uff0c\u540c\u65f6\u652f\u6301\u591a\u7ef4\u6570\u7ec4\u64cd\u4f5c\u3002\u6b64\u5916\uff0cndarray\u6570\u7ec4\u7684\u6240\u6709\u5143\u7d20\u5fc5\u987b\u5177\u6709\u76f8\u540c\u7684\u6570\u636e\u7c7b\u578b\uff0c\u8fd9\u4f7f\u5f97\u5b83\u5728\u6570\u503c\u8ba1\u7b97\u65b9\u9762\u66f4\u4e3a\u9ad8\u6548\uff0c\u800c\u5217\u8868\u5219\u53ef\u4ee5\u5305\u542b\u4e0d\u540c\u7c7b\u578b\u7684\u5143\u7d20\u3002<\/p>\n<p><strong>\u5982\u4f55\u4f7f\u7528ndarray\u6570\u7ec4\u8fdb\u884c\u6570\u5b66\u8fd0\u7b97\uff1f<\/strong><br \/>ndarray\u6570\u7ec4\u652f\u6301\u591a\u79cd\u6570\u5b66\u8fd0\u7b97\uff0c\u5305\u62ec\u52a0\u6cd5\u3001\u51cf\u6cd5\u3001\u4e58\u6cd5\u548c\u9664\u6cd5\u7b49\u3002\u60a8\u53ef\u4ee5\u76f4\u63a5\u5bf9\u6570\u7ec4\u8fdb\u884c\u8fd9\u4e9b\u64cd\u4f5c\uff0cNumPy\u4f1a\u81ea\u52a8\u8fdb\u884c\u5143\u7d20\u7ea7\u522b\u7684\u8fd0\u7b97\u3002\u4f8b\u5982\uff0c<code>a + b<\/code>\u5c06\u8ba1\u7b97\u4e24\u4e2a\u6570\u7ec4a\u548cb\u7684\u5bf9\u5e94\u5143\u7d20\u4e4b\u548c\u3002\u6b64\u5916\uff0cNumPy\u8fd8\u63d0\u4f9b\u4e86\u8bb8\u591a\u5185\u7f6e\u51fd\u6570\uff0c\u5982<code>numpy.sum()<\/code>\u3001<code>numpy.mean()<\/code>\u7b49\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u8fd9\u4e9b\u51fd\u6570\u5bf9\u6570\u7ec4\u8fdb\u884c\u66f4\u590d\u6742\u7684\u6570\u5b66\u8ba1\u7b97\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python\u4e2d\u521b\u5efandarray\u6570\u7ec4\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528NumPy\u5e93\u5b9e\u73b0\uff0c\u65b9\u6cd5\u5305\u62ec\uff1a\u4f7f\u7528array()\u51fd\u6570\u4ece\u5217\u8868\u6216\u5143 [&hellip;]","protected":false},"author":3,"featured_media":958479,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/958471"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=958471"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/958471\/revisions"}],"predecessor-version":[{"id":958480,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/958471\/revisions\/958480"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/958479"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=958471"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=958471"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=958471"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}