{"id":1009162,"date":"2024-12-27T11:09:23","date_gmt":"2024-12-27T03:09:23","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1009162.html"},"modified":"2024-12-27T11:09:27","modified_gmt":"2024-12-27T03:09:27","slug":"python%e5%b9%b3%e6%96%b9%e5%a6%82%e4%bd%95%e8%a1%a8%e7%a4%banumpy","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1009162.html","title":{"rendered":"python\u5e73\u65b9\u5982\u4f55\u8868\u793anumpy"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25084209\/8b0c171d-52f6-4667-ba2f-2b7d684c0fab.webp\" alt=\"python\u5e73\u65b9\u5982\u4f55\u8868\u793anumpy\" \/><\/p>\n<p><p> \u5728Python\u4e2d\uff0c\u4f7f\u7528NumPy\u5e93\u6765\u8868\u793a\u5e73\u65b9\u8fd0\u7b97\u662f\u975e\u5e38\u7b80\u5355\u548c\u9ad8\u6548\u7684\u3002<strong>\u53ef\u4ee5\u901a\u8fc7NumPy\u7684\u5e42\u8fd0\u7b97\u7b26<code>&lt;\/strong&gt;<\/code>\u3001<code>np.power<\/code>\u51fd\u6570\u3001\u4ee5\u53ca\u76f4\u63a5\u7684\u6570\u7ec4\u64cd\u4f5c\u6765\u5b9e\u73b0<strong>\u3002\u5176\u4e2d\uff0c\u4f7f\u7528\u5e42\u8fd0\u7b97\u7b26<code>&lt;\/strong&gt;<\/code>\u662f\u6700\u7b80\u6d01\u7684\u65b9\u5f0f\uff0c\u800c<code>np.power<\/code>\u51fd\u6570\u5219\u63d0\u4f9b\u4e86\u66f4\u597d\u7684\u53ef\u8bfb\u6027\u548c\u7075\u6d3b\u6027\u3002\u4e0b\u9762\u8be6\u7ec6\u63cf\u8ff0\u5982\u4f55\u4f7f\u7528\u8fd9\u4e9b\u65b9\u6cd5\u6765\u5b9e\u73b0\u5e73\u65b9\u8fd0\u7b97\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u4f7f\u7528\u5e42\u8fd0\u7b97\u7b26<code><\/code><\/h3>\n<\/p>\n<p><p>\u5728NumPy\u4e2d\uff0c\u5e42\u8fd0\u7b97\u7b26<code>&lt;strong&gt;<\/code>\u53ef\u4ee5\u76f4\u63a5\u7528\u4e8e\u6570\u7ec4\u8fd0\u7b97\u3002\u5047\u8bbe\u4f60\u6709\u4e00\u4e2aNumPy\u6570\u7ec4\uff0c\u4f60\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528<code>&lt;\/strong&gt;<\/code>\u8fd0\u7b97\u7b26\u6765\u8ba1\u7b97\u6bcf\u4e2a\u5143\u7d20\u7684\u5e73\u65b9\u3002\u8fd9\u4e2a\u64cd\u4f5c\u975e\u5e38\u76f4\u89c2\u4e14\u6613\u4e8e\u7406\u89e3\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2aNumPy\u6570\u7ec4<\/strong><\/h2>\n<p>arr = np.array([1, 2, 3, 4, 5])<\/p>\n<h2><strong>\u4f7f\u7528\u5e42\u8fd0\u7b97\u7b26\u8ba1\u7b97\u5e73\u65b9<\/strong><\/h2>\n<p>squared = arr  2<\/p>\n<p>print(squared)  # \u8f93\u51fa: [ 1  4  9 16 25]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u79cd\u65b9\u6cd5\u5728\u6027\u80fd\u4e0a\u975e\u5e38\u9ad8\u6548\uff0c\u56e0\u4e3aNumPy\u5728\u5e95\u5c42\u4f7f\u7528\u4e86\u4f18\u5316\u7684C\u8bed\u8a00\u4ee3\u7801\u6765\u5904\u7406\u6570\u7ec4\u64cd\u4f5c\u3002\u56e0\u6b64\uff0c\u4e0ePython\u7684\u5185\u7f6e\u5217\u8868\u76f8\u6bd4\uff0c\u5b83\u5728\u5927\u89c4\u6a21\u6570\u636e\u5904\u7406\u4e0a\u5177\u6709\u663e\u8457\u7684\u6027\u80fd\u4f18\u52bf\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u4f7f\u7528<code>np.power<\/code>\u51fd\u6570<\/h3>\n<\/p>\n<p><p>NumPy\u63d0\u4f9b\u4e86\u4e00\u4e2a\u4e13\u95e8\u7684\u51fd\u6570<code>np.power<\/code>\u6765\u8fdb\u884c\u5e42\u8fd0\u7b97\u3002<strong>\u8fd9\u4e2a\u51fd\u6570\u4e0d\u4ec5\u7528\u4e8e\u5e73\u65b9\u8fd0\u7b97\uff0c\u8fd8\u53ef\u4ee5\u7528\u4e8e\u8ba1\u7b97\u4efb\u610f\u6b21\u5e42<\/strong>\u3002<code>np.power<\/code>\u51fd\u6570\u80fd\u591f\u5904\u7406\u6807\u91cf\u548c\u6570\u7ec4\u4f5c\u4e3a\u8f93\u5165\uff0c\u5e76\u8fd4\u56de\u76f8\u5e94\u7684\u5e42\u8fd0\u7b97\u7ed3\u679c\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2aNumPy\u6570\u7ec4<\/strong><\/h2>\n<p>arr = np.array([1, 2, 3, 4, 5])<\/p>\n<h2><strong>\u4f7f\u7528np.power\u51fd\u6570\u8ba1\u7b97\u5e73\u65b9<\/strong><\/h2>\n<p>squared = np.power(arr, 2)<\/p>\n<p>print(squared)  # \u8f93\u51fa: [ 1  4  9 16 25]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4f7f\u7528<code>np.power<\/code>\u51fd\u6570\u7684\u597d\u5904\u5728\u4e8e\u5b83\u7684\u53ef\u8bfb\u6027\u66f4\u9ad8\uff0c\u5c24\u5176\u662f\u5728\u5904\u7406\u66f4\u9ad8\u6b21\u5e42\u6216\u8005\u9700\u8981\u52a8\u6001\u8bbe\u7f6e\u5e42\u6307\u6570\u7684\u60c5\u51b5\u4e0b\u3002\u6b64\u5916\uff0c\u5b83\u8fd8\u53ef\u4ee5\u5904\u7406\u4e0d\u540c\u5f62\u72b6\u7684\u6570\u7ec4\u4e4b\u95f4\u7684\u5e7f\u64ad\u8fd0\u7b97\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001NumPy\u6570\u7ec4\u7684\u76f4\u63a5\u64cd\u4f5c<\/h3>\n<\/p>\n<p><p>\u9664\u4e86\u4e0a\u8ff0\u65b9\u6cd5\uff0cNumPy\u6570\u7ec4\u7684\u76f4\u63a5\u64cd\u4f5c\u4e5f\u662f\u8ba1\u7b97\u5e73\u65b9\u7684\u5e38\u7528\u65b9\u5f0f\u3002<strong>\u7531\u4e8eNumPy\u6570\u7ec4\u652f\u6301\u5143\u7d20\u7ea7\u8fd0\u7b97\uff0c\u56e0\u6b64\u53ef\u4ee5\u76f4\u63a5\u5bf9\u6570\u7ec4\u6267\u884c\u6570\u5b66\u64cd\u4f5c\uff0c\u800c\u4e0d\u9700\u8981\u663e\u5f0f\u5730\u4f7f\u7528\u5faa\u73af<\/strong>\u3002\u8fd9\u79cd\u64cd\u4f5c\u65b9\u5f0f\u5728\u5904\u7406\u5927\u89c4\u6a21\u6570\u636e\u65f6\u5c24\u5176\u9ad8\u6548\uff0c\u56e0\u4e3a\u5b83\u907f\u514d\u4e86Python\u5c42\u9762\u7684\u5faa\u73af\u5f00\u9500\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2aNumPy\u6570\u7ec4<\/strong><\/h2>\n<p>arr = np.array([1, 2, 3, 4, 5])<\/p>\n<h2><strong>\u76f4\u63a5\u5bf9\u6570\u7ec4\u8fdb\u884c\u5e73\u65b9\u8fd0\u7b97<\/strong><\/h2>\n<p>squared = arr * arr<\/p>\n<p>print(squared)  # \u8f93\u51fa: [ 1  4  9 16 25]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u79cd\u65b9\u6cd5\u867d\u7136\u6ca1\u6709\u4f7f\u7528<code><\/code>\u6216\u8005<code>np.power<\/code>\uff0c\u4f46\u5728\u529f\u80fd\u4e0a\u662f\u7b49\u4ef7\u7684\uff0c\u800c\u4e14\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\u53ef\u80fd\u66f4\u52a0\u9ad8\u6548\uff0c\u5c24\u5176\u662f\u5728\u5904\u7406\u7b80\u5355\u7684\u5e73\u65b9\u8fd0\u7b97\u65f6\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u6027\u80fd\u6bd4\u8f83\u4e0e\u9009\u62e9<\/h3>\n<\/p>\n<p><p>\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u9009\u62e9\u54ea\u79cd\u65b9\u6cd5\u6765\u8fdb\u884c\u5e73\u65b9\u8fd0\u7b97\u901a\u5e38\u53d6\u51b3\u4e8e\u5177\u4f53\u7684\u9700\u6c42\u548c\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u3002<strong>\u5728\u6027\u80fd\u65b9\u9762\uff0c\u4f7f\u7528NumPy\u7684\u5411\u91cf\u5316\u8fd0\u7b97\uff08\u5982<code>&lt;\/strong&gt;<\/code>\u6216\u76f4\u63a5\u64cd\u4f5c\uff09\u901a\u5e38\u4f18\u4e8e\u5faa\u73af\u64cd\u4f5c\u3002\u7136\u800c\uff0c\u5728\u6d89\u53ca\u590d\u6742\u8fd0\u7b97\u6216\u9700\u8981\u52a8\u6001\u8ba1\u7b97\u5e42\u6307\u6570\u7684\u60c5\u51b5\u4e0b\uff0c<code>np.power<\/code>\u51fd\u6570\u53ef\u80fd\u4f1a\u63d0\u4f9b\u66f4\u597d\u7684\u53ef\u8bfb\u6027\u548c\u7075\u6d3b\u6027\u3002<\/p>\n<\/p>\n<p><h4>\u6027\u80fd\u6d4b\u8bd5<\/h4>\n<\/p>\n<p><p>\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u7b80\u5355\u7684\u6027\u80fd\u6d4b\u8bd5\u6765\u6bd4\u8f83\u8fd9\u4e9b\u65b9\u6cd5\u7684\u6548\u7387\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<p>import time<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2a\u5927\u89c4\u6a21NumPy\u6570\u7ec4<\/strong><\/h2>\n<p>arr = np.arange(1e6)<\/p>\n<h2><strong>\u6d4b\u8bd5\u5e42\u8fd0\u7b97\u7b26<\/strong><\/h2>\n<p>start_time = time.time()<\/p>\n<p>squared = arr  2<\/p>\n<p>print(&quot;\u5e42\u8fd0\u7b97\u7b26\u8017\u65f6: &quot;, time.time() - start_time)<\/p>\n<h2><strong>\u6d4b\u8bd5np.power\u51fd\u6570<\/strong><\/h2>\n<p>start_time = time.time()<\/p>\n<p>squared = np.power(arr, 2)<\/p>\n<p>print(&quot;np.power\u51fd\u6570\u8017\u65f6: &quot;, time.time() - start_time)<\/p>\n<h2><strong>\u6d4b\u8bd5\u76f4\u63a5\u64cd\u4f5c<\/strong><\/h2>\n<p>start_time = time.time()<\/p>\n<p>squared = arr * arr<\/p>\n<p>print(&quot;\u76f4\u63a5\u64cd\u4f5c\u8017\u65f6: &quot;, time.time() - start_time)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u4e0a\u8ff0\u6027\u80fd\u6d4b\u8bd5\uff0c\u6211\u4eec\u901a\u5e38\u4f1a\u53d1\u73b0\uff0c\u76f4\u63a5\u64cd\u4f5c\u548c<code><\/code>\u8fd0\u7b97\u7b26\u7684\u6027\u80fd\u975e\u5e38\u63a5\u8fd1\uff0c\u800c<code>np.power<\/code>\u51fd\u6570\u7531\u4e8e\u5176\u901a\u7528\u6027\uff0c\u53ef\u80fd\u7a0d\u5fae\u6162\u4e00\u70b9\uff0c\u4f46\u5dee\u5f02\u5e76\u4e0d\u660e\u663e\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001\u5e94\u7528\u573a\u666f<\/h3>\n<\/p>\n<p><p>\u5e73\u65b9\u8fd0\u7b97\u5728\u6570\u636e\u5904\u7406\u3001\u79d1\u5b66\u8ba1\u7b97\u3001<a href=\"https:\/\/docs.pingcode.com\/ask\/59192.html\" target=\"_blank\">\u673a\u5668\u5b66\u4e60<\/a>\u7b49\u9886\u57df\u6709\u7740\u5e7f\u6cdb\u7684\u5e94\u7528\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u89c1\u7684\u5e94\u7528\u573a\u666f\uff1a<\/p>\n<\/p>\n<p><h4>\u6570\u636e\u6807\u51c6\u5316<\/h4>\n<\/p>\n<p><p>\u5728\u673a\u5668\u5b66\u4e60\u548c\u6570\u636e\u6316\u6398\u4e2d\uff0c\u5e38\u5e38\u9700\u8981\u5bf9\u6570\u636e\u8fdb\u884c\u6807\u51c6\u5316\u5904\u7406\u3002\u5e73\u65b9\u8fd0\u7b97\u53ef\u4ee5\u7528\u4e8e\u8ba1\u7b97\u6807\u51c6\u5dee\u7b49\u7edf\u8ba1\u91cf\uff0c\u4ece\u800c\u5e2e\u52a9\u6211\u4eec\u66f4\u597d\u5730\u7406\u89e3\u6570\u636e\u5206\u5e03\u3002<\/p>\n<\/p>\n<p><h4>\u77e9\u9635\u8fd0\u7b97<\/h4>\n<\/p>\n<p><p>\u5728\u6570\u503c\u8ba1\u7b97\u4e2d\uff0c\u77e9\u9635\u7684\u5e73\u65b9\u8fd0\u7b97\u662f\u5e38\u89c1\u7684\u64cd\u4f5c\u4e4b\u4e00\u3002NumPy\u63d0\u4f9b\u7684\u9ad8\u6548\u6570\u7ec4\u8fd0\u7b97\u529f\u80fd\uff0c\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u5feb\u901f\u5b9e\u73b0\u77e9\u9635\u5e73\u65b9\u3002<\/p>\n<\/p>\n<p><h4>\u56fe\u50cf\u5904\u7406<\/h4>\n<\/p>\n<p><p>\u5728\u56fe\u50cf\u5904\u7406\u9886\u57df\uff0c\u5e73\u65b9\u8fd0\u7b97\u5e38\u7528\u4e8e\u8ba1\u7b97\u50cf\u7d20\u503c\u7684\u5e73\u65b9\u548c\uff0c\u4ece\u800c\u7528\u4e8e\u6ee4\u6ce2\u548c\u7279\u5f81\u63d0\u53d6\u7b49\u64cd\u4f5c\u3002<\/p>\n<\/p>\n<p><h3>\u516d\u3001\u6ce8\u610f\u4e8b\u9879<\/h3>\n<\/p>\n<p><p>\u5728\u4f7f\u7528NumPy\u8fdb\u884c\u5e73\u65b9\u8fd0\u7b97\u65f6\uff0c\u9700\u8981\u6ce8\u610f\u4ee5\u4e0b\u51e0\u70b9\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u6570\u636e\u7c7b\u578b<\/strong>\uff1aNumPy\u6570\u7ec4\u7684\u5143\u7d20\u7c7b\u578b\u4f1a\u5f71\u54cd\u8ba1\u7b97\u7ed3\u679c\u7684\u7cbe\u5ea6\u548c\u8303\u56f4\u3002\u5728\u8fdb\u884c\u5e73\u65b9\u8fd0\u7b97\u65f6\uff0c\u8981\u786e\u4fdd\u6570\u636e\u7c7b\u578b\u8db3\u591f\u5927\uff0c\u4ee5\u907f\u514d\u6ea2\u51fa\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5185\u5b58\u4f7f\u7528<\/strong>\uff1a\u5bf9\u4e8e\u5927\u89c4\u6a21\u6570\u636e\uff0cNumPy\u4f1a\u5728\u5185\u5b58\u4e2d\u521b\u5efa\u65b0\u7684\u6570\u7ec4\u6765\u5b58\u50a8\u8ba1\u7b97\u7ed3\u679c\u3002\u56e0\u6b64\uff0c\u5728\u5904\u7406\u8d85\u5927\u89c4\u6a21\u6570\u636e\u65f6\uff0c\u9700\u8981\u6ce8\u610f\u5185\u5b58\u7684\u4f7f\u7528\u60c5\u51b5\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5e7f\u64ad\u673a\u5236<\/strong>\uff1aNumPy\u7684\u5e7f\u64ad\u673a\u5236\u5141\u8bb8\u5bf9\u4e0d\u540c\u5f62\u72b6\u7684\u6570\u7ec4\u8fdb\u884c\u8fd0\u7b97\u3002\u5728\u8fdb\u884c\u5e73\u65b9\u8fd0\u7b97\u65f6\uff0c\u8981\u786e\u4fdd\u6570\u7ec4\u7684\u5f62\u72b6\u548c\u7ef4\u5ea6\u5339\u914d\uff0c\u4ee5\u907f\u514d\u4e0d\u5fc5\u8981\u7684\u9519\u8bef\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u4e03\u3001\u7ed3\u8bba<\/h3>\n<\/p>\n<p><p>\u5728Python\u4e2d\u4f7f\u7528NumPy\u8fdb\u884c\u5e73\u65b9\u8fd0\u7b97\u662f\u4e00\u79cd\u9ad8\u6548\u4e14\u7075\u6d3b\u7684\u9009\u62e9\u3002\u901a\u8fc7\u4f7f\u7528\u5e42\u8fd0\u7b97\u7b26<code><\/code>\u3001<code>np.power<\/code>\u51fd\u6570\u4ee5\u53ca\u76f4\u63a5\u7684\u6570\u7ec4\u64cd\u4f5c\uff0c\u6211\u4eec\u53ef\u4ee5\u8f7b\u677e\u5730\u5b9e\u73b0\u5404\u79cd\u5e73\u65b9\u8fd0\u7b97\u9700\u6c42\u3002\u5728\u5177\u4f53\u5e94\u7528\u4e2d\uff0c\u6839\u636e\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\uff0c\u4e0d\u4ec5\u53ef\u4ee5\u63d0\u9ad8\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\uff0c\u8fd8\u80fd\u4f18\u5316\u7a0b\u5e8f\u7684\u6267\u884c\u6548\u7387\u3002\u65e0\u8bba\u662f\u6570\u636e\u5206\u6790\u3001\u79d1\u5b66\u8ba1\u7b97\uff0c\u8fd8\u662f\u673a\u5668\u5b66\u4e60\uff0cNumPy\u7684\u5f3a\u5927\u529f\u80fd\u90fd\u80fd\u4e3a\u6211\u4eec\u63d0\u4f9b\u6709\u529b\u7684\u652f\u6301\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728NumPy\u4e2d\u8ba1\u7b97\u6570\u7ec4\u7684\u5e73\u65b9\uff1f<\/strong><br \/>\u5728NumPy\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528<code>numpy.square()<\/code>\u51fd\u6570\u6765\u8ba1\u7b97\u6570\u7ec4\u4e2d\u6bcf\u4e2a\u5143\u7d20\u7684\u5e73\u65b9\u3002\u4f8b\u5982\uff0c\u5982\u679c\u4f60\u6709\u4e00\u4e2aNumPy\u6570\u7ec4<code>arr = np.array([1, 2, 3])<\/code>\uff0c\u53ef\u4ee5\u901a\u8fc7<code>np.square(arr)<\/code>\u5f97\u5230<code>array([1, 4, 9])<\/code>\u3002<\/p>\n<p><strong>NumPy\u7684\u5e73\u65b9\u8fd0\u7b97\u662f\u5426\u652f\u6301\u5e7f\u64ad\uff1f<\/strong><br \/>\u662f\u7684\uff0cNumPy\u7684\u5e73\u65b9\u8fd0\u7b97\u652f\u6301\u5e7f\u64ad\u3002\u8fd9\u610f\u5473\u7740\u5982\u679c\u4f60\u6709\u4e00\u4e2a\u8f83\u5c0f\u7684\u6570\u7ec4\u548c\u4e00\u4e2a\u8f83\u5927\u7684\u6570\u7ec4\uff0cNumPy\u4f1a\u81ea\u52a8\u6269\u5c55\u8f83\u5c0f\u7684\u6570\u7ec4\u4ee5\u5339\u914d\u8f83\u5927\u7684\u6570\u7ec4\u7684\u5f62\u72b6\uff0c\u4ece\u800c\u8fdb\u884c\u5e73\u65b9\u8fd0\u7b97\u3002\u4f8b\u5982\uff0c\u5f53\u4f60\u5c06\u4e00\u4e2a\u4e00\u7ef4\u6570\u7ec4\u7684\u5e73\u65b9\u4e0e\u4e00\u4e2a\u4e8c\u7ef4\u6570\u7ec4\u7684\u5e73\u65b9\u76f8\u52a0\u65f6\uff0cNumPy\u4f1a\u6839\u636e\u9700\u8981\u8fdb\u884c\u5f62\u72b6\u8c03\u6574\u3002<\/p>\n<p><strong>\u5728NumPy\u4e2d\u8ba1\u7b97\u5e73\u65b9\u4e0e\u76f4\u63a5\u4e58\u6cd5\u6709\u4ec0\u4e48\u533a\u522b\uff1f<\/strong><br \/>\u4f7f\u7528<code>numpy.square()<\/code>\u548c\u76f4\u63a5\u901a\u8fc7\u4e58\u6cd5\u8ba1\u7b97\u5e73\u65b9\uff08\u5982<code>arr * arr<\/code>\uff09\u5728\u7ed3\u679c\u4e0a\u662f\u76f8\u540c\u7684\uff0c\u4f46\u5728\u53ef\u8bfb\u6027\u4e0a\u6709\u6240\u533a\u522b\u3002<code>numpy.square()<\/code>\u660e\u786e\u8868\u793a\u8fd9\u662f\u4e00\u4e2a\u5e73\u65b9\u64cd\u4f5c\uff0c\u4ee3\u7801\u7684\u610f\u56fe\u66f4\u52a0\u6e05\u6670\u3002\u6b64\u5916\uff0c\u4f7f\u7528<code>numpy.square()<\/code>\u53ef\u4ee5\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\u63d0\u4f9b\u66f4\u597d\u7684\u6027\u80fd\uff0c\u5c24\u5176\u662f\u5728\u5904\u7406\u5927\u578b\u6570\u7ec4\u65f6\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python\u4e2d\uff0c\u4f7f\u7528NumPy\u5e93\u6765\u8868\u793a\u5e73\u65b9\u8fd0\u7b97\u662f\u975e\u5e38\u7b80\u5355\u548c\u9ad8\u6548\u7684\u3002\u53ef\u4ee5\u901a\u8fc7NumPy\u7684\u5e42\u8fd0\u7b97\u7b26&lt;\/st [&hellip;]","protected":false},"author":3,"featured_media":1009172,"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\/1009162"}],"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=1009162"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1009162\/revisions"}],"predecessor-version":[{"id":1009174,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1009162\/revisions\/1009174"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1009172"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1009162"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1009162"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1009162"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}