{"id":1080136,"date":"2025-01-08T12:27:19","date_gmt":"2025-01-08T04:27:19","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1080136.html"},"modified":"2025-01-08T12:27:21","modified_gmt":"2025-01-08T04:27:21","slug":"%e5%a6%82%e4%bd%95%e7%94%a8python%e6%9e%84%e6%88%90%e5%9b%9b%e7%bb%b4%e6%95%b0%e7%bb%84-2","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1080136.html","title":{"rendered":"\u5982\u4f55\u7528python\u6784\u6210\u56db\u7ef4\u6570\u7ec4"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24182820\/e4b6c8b4-184e-4c37-91df-e2647edf7ac7.webp\" alt=\"\u5982\u4f55\u7528python\u6784\u6210\u56db\u7ef4\u6570\u7ec4\" \/><\/p>\n<p><p> <strong>\u4f7f\u7528Python\u6784\u5efa\u56db\u7ef4\u6570\u7ec4\u7684\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u5e38\u89c1\u7684\u65b9\u6cd5\u5305\u62ec\u4f7f\u7528NumPy\u5e93\u3001\u5217\u8868\u63a8\u5bfc\u5f0f\u3001\u4ee5\u53ca\u5d4c\u5957\u5faa\u73af\u7b49\u3002\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u8fd9\u4e9b\u65b9\u6cd5\uff0c\u5e76\u4e14\u91cd\u70b9\u5c55\u5f00NumPy\u5e93\u5728\u6784\u5efa\u56db\u7ef4\u6570\u7ec4\u4e2d\u7684\u5e94\u7528\u3002<\/strong><\/p>\n<\/p>\n<p><p>NumPy\u5e93\u662fPython\u4e2d\u5904\u7406\u6570\u7ec4\u548c\u77e9\u9635\u8fd0\u7b97\u7684\u5f3a\u5927\u5de5\u5177\uff0c\u5177\u6709\u9ad8\u6548\u7684\u591a\u7ef4\u6570\u7ec4\u5904\u7406\u80fd\u529b\u3001\u7b80\u6d01\u7684\u8bed\u6cd5\u548c\u4e30\u5bcc\u7684\u51fd\u6570\u5e93\uff0c\u662f\u6784\u5efa\u56db\u7ef4\u6570\u7ec4\u7684\u9996\u9009\u5de5\u5177\u3002\u901a\u8fc7\u4f7f\u7528NumPy\u5e93\uff0c\u7528\u6237\u53ef\u4ee5\u8f7b\u677e\u5730\u521b\u5efa\u548c\u64cd\u4f5c\u56db\u7ef4\u6570\u7ec4\uff0c\u6267\u884c\u5404\u79cd\u79d1\u5b66\u8ba1\u7b97\u548c\u6570\u636e\u5904\u7406\u4efb\u52a1\u3002<\/p>\n<\/p>\n<p><h2>\u4e00\u3001\u4f7f\u7528NumPy\u5e93\u6784\u5efa\u56db\u7ef4\u6570\u7ec4<\/h2>\n<\/p>\n<p><h3>1.1 \u5b89\u88c5NumPy\u5e93<\/h3>\n<\/p>\n<p><p>\u5728\u5f00\u59cb\u4f7f\u7528NumPy\u5e93\u4e4b\u524d\uff0c\u9996\u5148\u9700\u8981\u786e\u4fdd\u5df2\u5b89\u88c5NumPy\u5e93\u3002\u5982\u679c\u5c1a\u672a\u5b89\u88c5\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u901a\u8fc7pip\u8fdb\u884c\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><h3>1.2 \u521b\u5efa\u56db\u7ef4\u6570\u7ec4<\/h3>\n<\/p>\n<p><p>\u4f7f\u7528NumPy\u5e93\u521b\u5efa\u56db\u7ef4\u6570\u7ec4\u975e\u5e38\u7b80\u5355\uff0c\u53ef\u4ee5\u901a\u8fc7<code>numpy.array<\/code>\u51fd\u6570\u6216\u8005<code>numpy.zeros<\/code>\u3001<code>numpy.ones<\/code>\u7b49\u51fd\u6570\u5b9e\u73b0\u3002\u4e0b\u9762\u662f\u4e00\u4e9b\u5e38\u7528\u7684\u65b9\u6cd5\uff1a<\/p>\n<\/p>\n<p><h4>1.2.1 \u4f7f\u7528numpy.array\u51fd\u6570<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<h2><strong>\u4f7f\u7528numpy.array\u51fd\u6570\u521b\u5efa\u56db\u7ef4\u6570\u7ec4<\/strong><\/h2>\n<p>array_4d = np.array([[[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]],<\/p>\n<p>                     [[[13, 14, 15], [16, 17, 18]], [[19, 20, 21], [22, 23, 24]]]])<\/p>\n<p>print(array_4d)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>1.2.2 \u4f7f\u7528numpy.zeros\u51fd\u6570<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<h2><strong>\u4f7f\u7528numpy.zeros\u51fd\u6570\u521b\u5efa\u4e00\u4e2a\u5168\u96f6\u7684\u56db\u7ef4\u6570\u7ec4<\/strong><\/h2>\n<p>array_4d = np.zeros((2, 2, 2, 3))<\/p>\n<p>print(array_4d)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>1.2.3 \u4f7f\u7528numpy.ones\u51fd\u6570<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<h2><strong>\u4f7f\u7528numpy.ones\u51fd\u6570\u521b\u5efa\u4e00\u4e2a\u5168\u4e00\u7684\u56db\u7ef4\u6570\u7ec4<\/strong><\/h2>\n<p>array_4d = np.ones((2, 2, 2, 3))<\/p>\n<p>print(array_4d)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>1.3 \u64cd\u4f5c\u56db\u7ef4\u6570\u7ec4<\/h3>\n<\/p>\n<p><p>\u521b\u5efa\u56db\u7ef4\u6570\u7ec4\u540e\uff0c\u53ef\u4ee5\u5bf9\u5176\u8fdb\u884c\u5404\u79cd\u64cd\u4f5c\uff0c\u4f8b\u5982\u8bbf\u95ee\u5143\u7d20\u3001\u4fee\u6539\u5143\u7d20\u3001\u8fdb\u884c\u6570\u5b66\u8fd0\u7b97\u7b49\u3002\u4e0b\u9762\u662f\u4e00\u4e9b\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><h4>1.3.1 \u8bbf\u95ee\u5143\u7d20<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2a\u56db\u7ef4\u6570\u7ec4<\/strong><\/h2>\n<p>array_4d = np.array([[[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]],<\/p>\n<p>                     [[[13, 14, 15], [16, 17, 18]], [[19, 20, 21], [22, 23, 24]]]])<\/p>\n<h2><strong>\u8bbf\u95ee\u6307\u5b9a\u4f4d\u7f6e\u7684\u5143\u7d20<\/strong><\/h2>\n<p>element = array_4d[1, 1, 0, 2]<\/p>\n<p>print(element)  # \u8f93\u51fa\uff1a21<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>1.3.2 \u4fee\u6539\u5143\u7d20<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2a\u56db\u7ef4\u6570\u7ec4<\/strong><\/h2>\n<p>array_4d = np.array([[[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]],<\/p>\n<p>                     [[[13, 14, 15], [16, 17, 18]], [[19, 20, 21], [22, 23, 24]]]])<\/p>\n<h2><strong>\u4fee\u6539\u6307\u5b9a\u4f4d\u7f6e\u7684\u5143\u7d20<\/strong><\/h2>\n<p>array_4d[1, 1, 0, 2] = 100<\/p>\n<p>print(array_4d)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>1.3.3 \u6570\u5b66\u8fd0\u7b97<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<h2><strong>\u521b\u5efa\u4e24\u4e2a\u56db\u7ef4\u6570\u7ec4<\/strong><\/h2>\n<p>array_4d_1 = np.array([[[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]],<\/p>\n<p>                       [[[13, 14, 15], [16, 17, 18]], [[19, 20, 21], [22, 23, 24]]]])<\/p>\n<p>array_4d_2 = np.ones((2, 2, 2, 3))<\/p>\n<h2><strong>\u8fdb\u884c\u52a0\u6cd5\u8fd0\u7b97<\/strong><\/h2>\n<p>result_add = array_4d_1 + array_4d_2<\/p>\n<p>print(result_add)<\/p>\n<h2><strong>\u8fdb\u884c\u4e58\u6cd5\u8fd0\u7b97<\/strong><\/h2>\n<p>result_mul = array_4d_1 * array_4d_2<\/p>\n<p>print(result_mul)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>\u4e8c\u3001\u4f7f\u7528\u5217\u8868\u63a8\u5bfc\u5f0f\u6784\u5efa\u56db\u7ef4\u6570\u7ec4<\/h2>\n<\/p>\n<p><h3>2.1 \u57fa\u672c\u65b9\u6cd5<\/h3>\n<\/p>\n<p><p>\u5217\u8868\u63a8\u5bfc\u5f0f\u662f\u4e00\u79cd\u7b80\u6d01\u7684\u521b\u5efa\u5217\u8868\u7684\u65b9\u6cd5\uff0c\u4e5f\u53ef\u4ee5\u7528\u4e8e\u6784\u5efa\u591a\u7ef4\u6570\u7ec4\u3002\u901a\u8fc7\u5d4c\u5957\u5217\u8868\u63a8\u5bfc\u5f0f\uff0c\u53ef\u4ee5\u6784\u5efa\u56db\u7ef4\u6570\u7ec4\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u4f7f\u7528\u5217\u8868\u63a8\u5bfc\u5f0f\u521b\u5efa\u56db\u7ef4\u6570\u7ec4<\/p>\n<p>array_4d = [[[[i + j + k + l for l in range(3)] for k in range(2)] for j in range(2)] for i in range(2)]<\/p>\n<p>print(array_4d)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2.2 \u64cd\u4f5c\u56db\u7ef4\u6570\u7ec4<\/h3>\n<\/p>\n<p><p>\u7c7b\u4f3c\u4e8eNumPy\u6570\u7ec4\uff0c\u53ef\u4ee5\u5bf9\u5217\u8868\u63a8\u5bfc\u5f0f\u521b\u5efa\u7684\u56db\u7ef4\u6570\u7ec4\u8fdb\u884c\u5404\u79cd\u64cd\u4f5c\uff0c\u4f8b\u5982\u8bbf\u95ee\u5143\u7d20\u3001\u4fee\u6539\u5143\u7d20\u7b49\u3002\u4e0b\u9762\u662f\u4e00\u4e9b\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><h4>2.2.1 \u8bbf\u95ee\u5143\u7d20<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\"># \u521b\u5efa\u4e00\u4e2a\u56db\u7ef4\u6570\u7ec4<\/p>\n<p>array_4d = [[[[i + j + k + l for l in range(3)] for k in range(2)] for j in range(2)] for i in range(2)]<\/p>\n<h2><strong>\u8bbf\u95ee\u6307\u5b9a\u4f4d\u7f6e\u7684\u5143\u7d20<\/strong><\/h2>\n<p>element = array_4d[1][1][0][2]<\/p>\n<p>print(element)  # \u8f93\u51fa\uff1a4<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2.2.2 \u4fee\u6539\u5143\u7d20<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\"># \u521b\u5efa\u4e00\u4e2a\u56db\u7ef4\u6570\u7ec4<\/p>\n<p>array_4d = [[[[i + j + k + l for l in range(3)] for k in range(2)] for j in range(2)] for i in range(2)]<\/p>\n<h2><strong>\u4fee\u6539\u6307\u5b9a\u4f4d\u7f6e\u7684\u5143\u7d20<\/strong><\/h2>\n<p>array_4d[1][1][0][2] = 100<\/p>\n<p>print(array_4d)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>\u4e09\u3001\u4f7f\u7528\u5d4c\u5957\u5faa\u73af\u6784\u5efa\u56db\u7ef4\u6570\u7ec4<\/h2>\n<\/p>\n<p><h3>3.1 \u57fa\u672c\u65b9\u6cd5<\/h3>\n<\/p>\n<p><p>\u5d4c\u5957\u5faa\u73af\u662f\u4e00\u79cd\u5e38\u89c1\u7684\u521b\u5efa\u591a\u7ef4\u6570\u7ec4\u7684\u65b9\u6cd5\uff0c\u901a\u8fc7\u591a\u5c42\u5faa\u73af\u53ef\u4ee5\u6784\u5efa\u56db\u7ef4\u6570\u7ec4\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u4f7f\u7528\u5d4c\u5957\u5faa\u73af\u521b\u5efa\u56db\u7ef4\u6570\u7ec4<\/p>\n<p>array_4d = []<\/p>\n<p>for i in range(2):<\/p>\n<p>    array_4d.append([])<\/p>\n<p>    for j in range(2):<\/p>\n<p>        array_4d[i].append([])<\/p>\n<p>        for k in range(2):<\/p>\n<p>            array_4d[i][j].append([])<\/p>\n<p>            for l in range(3):<\/p>\n<p>                array_4d[i][j][k].append(i + j + k + l)<\/p>\n<p>print(array_4d)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>3.2 \u64cd\u4f5c\u56db\u7ef4\u6570\u7ec4<\/h3>\n<\/p>\n<p><p>\u7c7b\u4f3c\u4e8e\u524d\u9762\u7684\u65b9\u6cd5\uff0c\u53ef\u4ee5\u5bf9\u5d4c\u5957\u5faa\u73af\u521b\u5efa\u7684\u56db\u7ef4\u6570\u7ec4\u8fdb\u884c\u5404\u79cd\u64cd\u4f5c\uff0c\u4f8b\u5982\u8bbf\u95ee\u5143\u7d20\u3001\u4fee\u6539\u5143\u7d20\u7b49\u3002\u4e0b\u9762\u662f\u4e00\u4e9b\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><h4>3.2.1 \u8bbf\u95ee\u5143\u7d20<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\"># \u521b\u5efa\u4e00\u4e2a\u56db\u7ef4\u6570\u7ec4<\/p>\n<p>array_4d = []<\/p>\n<p>for i in range(2):<\/p>\n<p>    array_4d.append([])<\/p>\n<p>    for j in range(2):<\/p>\n<p>        array_4d[i].append([])<\/p>\n<p>        for k in range(2):<\/p>\n<p>            array_4d[i][j].append([])<\/p>\n<p>            for l in range(3):<\/p>\n<p>                array_4d[i][j][k].append(i + j + k + l)<\/p>\n<h2><strong>\u8bbf\u95ee\u6307\u5b9a\u4f4d\u7f6e\u7684\u5143\u7d20<\/strong><\/h2>\n<p>element = array_4d[1][1][0][2]<\/p>\n<p>print(element)  # \u8f93\u51fa\uff1a4<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3.2.2 \u4fee\u6539\u5143\u7d20<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\"># \u521b\u5efa\u4e00\u4e2a\u56db\u7ef4\u6570\u7ec4<\/p>\n<p>array_4d = []<\/p>\n<p>for i in range(2):<\/p>\n<p>    array_4d.append([])<\/p>\n<p>    for j in range(2):<\/p>\n<p>        array_4d[i].append([])<\/p>\n<p>        for k in range(2):<\/p>\n<p>            array_4d[i][j].append([])<\/p>\n<p>            for l in range(3):<\/p>\n<p>                array_4d[i][j][k].append(i + j + k + l)<\/p>\n<h2><strong>\u4fee\u6539\u6307\u5b9a\u4f4d\u7f6e\u7684\u5143\u7d20<\/strong><\/h2>\n<p>array_4d[1][1][0][2] = 100<\/p>\n<p>print(array_4d)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>\u56db\u3001\u603b\u7ed3<\/h2>\n<\/p>\n<p><p>\u901a\u8fc7\u4e0a\u8ff0\u65b9\u6cd5\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528Python\u6784\u5efa\u5e76\u64cd\u4f5c\u56db\u7ef4\u6570\u7ec4\u3002<strong>\u4f7f\u7528NumPy\u5e93\u6784\u5efa\u56db\u7ef4\u6570\u7ec4\u662f\u6700\u63a8\u8350\u7684\u65b9\u6cd5\uff0c\u56e0\u4e3a\u5b83\u63d0\u4f9b\u4e86\u9ad8\u6548\u7684\u6570\u7ec4\u64cd\u4f5c\u548c\u4e30\u5bcc\u7684\u51fd\u6570\u5e93<\/strong>\u3002\u6b64\u5916\uff0c\u5217\u8868\u63a8\u5bfc\u5f0f\u548c\u5d4c\u5957\u5faa\u73af\u4e5f\u53ef\u4ee5\u7528\u4e8e\u6784\u5efa\u56db\u7ef4\u6570\u7ec4\uff0c\u9002\u5408\u4e8e\u4e0d\u540c\u7684\u7f16\u7a0b\u573a\u666f\u548c\u9700\u6c42\u3002<\/p>\n<\/p>\n<p><p>\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u6839\u636e\u5177\u4f53\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\u6784\u5efa\u56db\u7ef4\u6570\u7ec4\uff0c\u5e76\u5229\u7528Python\u5f3a\u5927\u7684\u6570\u636e\u5904\u7406\u80fd\u529b\uff0c\u5b8c\u6210\u5404\u79cd\u79d1\u5b66\u8ba1\u7b97\u548c\u6570\u636e\u5206\u6790\u4efb\u52a1\u3002\u5e0c\u671b\u672c\u6587\u5bf9\u60a8\u7406\u89e3\u548c\u4f7f\u7528Python\u6784\u5efa\u56db\u7ef4\u6570\u7ec4\u6709\u6240\u5e2e\u52a9\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u521b\u5efa\u56db\u7ef4\u6570\u7ec4\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528NumPy\u5e93\u6765\u521b\u5efa\u56db\u7ef4\u6570\u7ec4\u3002\u9996\u5148\uff0c\u9700\u8981\u5b89\u88c5NumPy\u5e93\uff0c\u5982\u679c\u5c1a\u672a\u5b89\u88c5\uff0c\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4<code>pip install numpy<\/code>\u8fdb\u884c\u5b89\u88c5\u3002\u63a5\u4e0b\u6765\uff0c\u53ef\u4ee5\u4f7f\u7528<code>numpy.zeros()<\/code>\u3001<code>numpy.ones()<\/code>\u6216<code>numpy.empty()<\/code>\u7b49\u51fd\u6570\u6765\u521b\u5efa\u56db\u7ef4\u6570\u7ec4\u3002\u4f8b\u5982\uff0c\u4f7f\u7528<code>numpy.zeros((a, b, c, d))<\/code>\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u5f62\u72b6\u4e3a(a, b, c, d)\u7684\u56db\u7ef4\u6570\u7ec4\uff0c\u6240\u6709\u5143\u7d20\u521d\u59cb\u5316\u4e3a\u96f6\u3002<\/p>\n<p><strong>\u56db\u7ef4\u6570\u7ec4\u7684\u5e94\u7528\u573a\u666f\u6709\u54ea\u4e9b\uff1f<\/strong><br \/>\u56db\u7ef4\u6570\u7ec4\u5728\u591a\u4e2a\u9886\u57df\u90fd\u6709\u5e7f\u6cdb\u5e94\u7528\u3002\u4f8b\u5982\uff0c\u5728\u8ba1\u7b97\u673a\u89c6\u89c9\u4e2d\uff0c\u56db\u7ef4\u6570\u7ec4\u53ef\u4ee5\u7528\u6765\u8868\u793a\u89c6\u9891\u6570\u636e\uff0c\u5176\u4e2d\u7b2c\u4e00\u7ef4\u8868\u793a\u89c6\u9891\u5e27\uff0c\u540e\u9762\u7684\u7ef4\u5ea6\u5206\u522b\u8868\u793a\u56fe\u50cf\u7684\u9ad8\u5ea6\u3001\u5bbd\u5ea6\u548c\u989c\u8272\u901a\u9053\u3002\u5728\u79d1\u5b66\u8ba1\u7b97\u4e2d\uff0c\u56db\u7ef4\u6570\u7ec4\u4e5f\u5e38\u7528\u4e8e\u5b58\u50a8\u591a\u7ef4\u6570\u636e\uff0c\u6bd4\u5982\u6c14\u8c61\u6570\u636e\u3001\u533b\u5b66\u6210\u50cf\u7b49\u3002<\/p>\n<p><strong>\u5982\u4f55\u5bf9\u56db\u7ef4\u6570\u7ec4\u8fdb\u884c\u64cd\u4f5c\u548c\u5904\u7406\uff1f<\/strong><br \/>\u5bf9\u56db\u7ef4\u6570\u7ec4\u7684\u64cd\u4f5c\u53ef\u4ee5\u4f7f\u7528NumPy\u63d0\u4f9b\u7684\u591a\u79cd\u529f\u80fd\u3002\u53ef\u4ee5\u8fdb\u884c\u5207\u7247\u3001\u7d22\u5f15\u3001\u6570\u5b66\u8fd0\u7b97\u7b49\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u901a\u8fc7<code>array[i]<\/code>\u8bbf\u95ee\u7279\u5b9a\u7684\u4e8c\u7ef4\u5207\u7247\uff0c\u6216\u8005\u4f7f\u7528<code>numpy.sum(array, axis=0)<\/code>\u5bf9\u6570\u7ec4\u7684\u67d0\u4e00\u7ef4\u8fdb\u884c\u6c42\u548c\u3002\u6b64\u5916\uff0cNumPy\u8fd8\u652f\u6301\u5e7f\u64ad\u64cd\u4f5c\uff0c\u4f7f\u5f97\u4e0d\u540c\u5f62\u72b6\u7684\u6570\u7ec4\u53ef\u4ee5\u8fdb\u884c\u8fd0\u7b97\uff0c\u6781\u5927\u5730\u63d0\u9ad8\u4e86\u8fd0\u7b97\u7684\u7075\u6d3b\u6027\u548c\u6548\u7387\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u4f7f\u7528Python\u6784\u5efa\u56db\u7ef4\u6570\u7ec4\u7684\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u5e38\u89c1\u7684\u65b9\u6cd5\u5305\u62ec\u4f7f\u7528NumPy\u5e93\u3001\u5217\u8868\u63a8\u5bfc\u5f0f\u3001\u4ee5\u53ca\u5d4c\u5957\u5faa\u73af\u7b49\u3002\u672c\u6587\u5c06\u8be6 [&hellip;]","protected":false},"author":3,"featured_media":1080149,"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\/1080136"}],"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=1080136"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1080136\/revisions"}],"predecessor-version":[{"id":1080154,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1080136\/revisions\/1080154"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1080149"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1080136"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1080136"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1080136"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}