{"id":1142195,"date":"2025-01-08T22:37:38","date_gmt":"2025-01-08T14:37:38","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1142195.html"},"modified":"2025-01-08T22:37:52","modified_gmt":"2025-01-08T14:37:52","slug":"python%e5%a6%82%e4%bd%95%e8%8e%b7%e5%8f%96%e4%ba%8c%e7%bb%b4%e6%95%b0%e7%bb%84%e6%8c%87%e5%ae%9a%e8%a1%8c%e6%95%b0%e6%8d%ae%e5%ba%93","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1142195.html","title":{"rendered":"python\u5982\u4f55\u83b7\u53d6\u4e8c\u7ef4\u6570\u7ec4\u6307\u5b9a\u884c\u6570\u636e\u5e93"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24180443\/821e84be-a9d0-47ed-bdd7-cff2f296f57f.webp\" alt=\"python\u5982\u4f55\u83b7\u53d6\u4e8c\u7ef4\u6570\u7ec4\u6307\u5b9a\u884c\u6570\u636e\u5e93\" \/><\/p>\n<p><p> <strong>Python \u83b7\u53d6\u4e8c\u7ef4\u6570\u7ec4\u6307\u5b9a\u884c\u6570\u636e\u7684\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u5305\u62ec\u4f7f\u7528\u57fa\u7840\u7684\u5217\u8868\u64cd\u4f5c\u3001NumPy\u5e93\u7b49\u3002<\/strong> \u5176\u4e2d\uff0cNumPy\u5e93\u662f\u5904\u7406\u591a\u7ef4\u6570\u7ec4\u7684\u5f3a\u5927\u5de5\u5177\uff0c\u5141\u8bb8\u6211\u4eec\u9ad8\u6548\u5730\u8fdb\u884c\u5404\u79cd\u6570\u7ec4\u64cd\u4f5c\u3002<strong>\u9996\u5148\uff0c\u5bfc\u5165NumPy\u5e93\u3001\u521b\u5efa\u4e8c\u7ef4\u6570\u7ec4\u3001\u4f7f\u7528\u7d22\u5f15\u64cd\u4f5c\u83b7\u53d6\u6307\u5b9a\u884c\u6570\u636e\u662f\u6700\u5e38\u89c1\u7684\u65b9\u6cd5\u3002<\/strong> \u4e0b\u9762\u6211\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u8fd9\u4e9b\u65b9\u6cd5\uff0c\u5e76\u63d0\u4f9b\u4ee3\u7801\u793a\u4f8b\u548c\u5177\u4f53\u5e94\u7528\u573a\u666f\u3002<\/p>\n<\/p>\n<hr>\n<h2><strong>\u4e00\u3001Python\u4e2d\u7684\u5217\u8868\u64cd\u4f5c<\/strong><\/h2>\n<p><h2>1\u3001\u521b\u5efa\u4e8c\u7ef4\u6570\u7ec4<\/h2>\n<\/p>\n<p><p>\u5728Python\u4e2d\uff0c\u4e8c\u7ef4\u6570\u7ec4\u901a\u5e38\u901a\u8fc7\u5d4c\u5957\u5217\u8868\u6765\u521b\u5efa\u3002\u6bcf\u4e2a\u5b50\u5217\u8868\u4ee3\u8868\u4e8c\u7ef4\u6570\u7ec4\u7684\u4e00\u884c\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">array = [<\/p>\n<p>    [1, 2, 3],<\/p>\n<p>    [4, 5, 6],<\/p>\n<p>    [7, 8, 9]<\/p>\n<p>]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>2\u3001\u83b7\u53d6\u6307\u5b9a\u884c\u6570\u636e<\/h2>\n<\/p>\n<p><p>\u8981\u83b7\u53d6\u4e8c\u7ef4\u6570\u7ec4\u4e2d\u7684\u6307\u5b9a\u884c\u6570\u636e\uff0c\u53ef\u4ee5\u4f7f\u7528\u5217\u8868\u7684\u7d22\u5f15\u64cd\u4f5c\u3002\u4f8b\u5982\uff0c\u8981\u83b7\u53d6\u7b2c\u4e8c\u884c\u6570\u636e\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">second_row = array[1]<\/p>\n<p>print(second_row)  # \u8f93\u51fa: [4, 5, 6]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\uff0c\u6211\u4eec\u53ef\u4ee5\u8f7b\u677e\u5730\u83b7\u53d6\u4e8c\u7ef4\u6570\u7ec4\u7684\u4efb\u4f55\u4e00\u884c\u6570\u636e\u3002<\/strong> \u5217\u8868\u7684\u7d22\u5f15\u4ece0\u5f00\u59cb\uff0c\u6240\u4ee5\u7b2c\u4e8c\u884c\u7684\u7d22\u5f15\u662f1\u3002<\/p>\n<\/p>\n<p><h2>3\u3001\u5904\u7406\u8fb9\u754c\u6761\u4ef6<\/h2>\n<\/p>\n<p><p>\u5728\u4f7f\u7528\u5217\u8868\u7d22\u5f15\u65f6\uff0c\u9700\u8981\u6ce8\u610f\u8fb9\u754c\u6761\u4ef6\u3002\u4f8b\u5982\uff0c\u5982\u679c\u7d22\u5f15\u8d85\u51fa\u4e86\u5217\u8868\u7684\u8303\u56f4\uff0c\u4f1a\u5f15\u53d1IndexError\u5f02\u5e38\u3002\u56e0\u6b64\uff0c\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u901a\u5e38\u4f1a\u5148\u68c0\u67e5\u7d22\u5f15\u662f\u5426\u5728\u6709\u6548\u8303\u56f4\u5185\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">index = 1<\/p>\n<p>if 0 &lt;= index &lt; len(array):<\/p>\n<p>    row_data = array[index]<\/p>\n<p>    print(row_data)<\/p>\n<p>else:<\/p>\n<p>    print(&quot;\u7d22\u5f15\u8d85\u51fa\u8303\u56f4&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<h2><strong>\u4e8c\u3001NumPy\u5e93\u7684\u4f7f\u7528<\/strong><\/h2>\n<p><p>NumPy\u662fPython\u4e2d\u5904\u7406\u591a\u7ef4\u6570\u7ec4\u7684\u57fa\u7840\u5e93\u3002\u5b83\u63d0\u4f9b\u4e86\u6bd4\u5d4c\u5957\u5217\u8868\u66f4\u9ad8\u6548\u548c\u66f4\u4e30\u5bcc\u7684\u64cd\u4f5c\u65b9\u5f0f\u3002<\/p>\n<\/p>\n<p><h2>1\u3001\u5b89\u88c5NumPy<\/h2>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u786e\u4fdd\u4f60\u7684\u73af\u5883\u4e2d\u5df2\u7ecf\u5b89\u88c5\u4e86NumPy\u5e93\u3002\u5982\u679c\u6ca1\u6709\u5b89\u88c5\uff0c\u53ef\u4ee5\u4f7f\u7528pip\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><h2>2\u3001\u521b\u5efaNumPy\u4e8c\u7ef4\u6570\u7ec4<\/h2>\n<\/p>\n<p><p>\u4f7f\u7528NumPy\u521b\u5efa\u4e8c\u7ef4\u6570\u7ec4\u975e\u5e38\u7b80\u5355\u3002\u53ef\u4ee5\u76f4\u63a5\u4ece\u5217\u8868\u521b\u5efa\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528NumPy\u7684\u5185\u7f6e\u51fd\u6570\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<h2><strong>\u4ece\u5217\u8868\u521b\u5efa<\/strong><\/h2>\n<p>array = np.array([<\/p>\n<p>    [1, 2, 3],<\/p>\n<p>    [4, 5, 6],<\/p>\n<p>    [7, 8, 9]<\/p>\n<p>])<\/p>\n<h2><strong>\u4f7f\u7528\u5185\u7f6e\u51fd\u6570\u521b\u5efa<\/strong><\/h2>\n<p>array_zeros = np.zeros((3, 3))  # \u521b\u5efa\u4e00\u4e2a3x3\u7684\u5168\u96f6\u6570\u7ec4<\/p>\n<p>array_ones = np.ones((3, 3))    # \u521b\u5efa\u4e00\u4e2a3x3\u7684\u5168\u4e00\u6570\u7ec4<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>3\u3001\u83b7\u53d6\u6307\u5b9a\u884c\u6570\u636e<\/h2>\n<\/p>\n<p><p>\u5728NumPy\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u6570\u7ec4\u7684\u7d22\u5f15\u64cd\u4f5c\u6765\u83b7\u53d6\u6307\u5b9a\u884c\u7684\u6570\u636e\u3002\u4e0e\u5217\u8868\u64cd\u4f5c\u7c7b\u4f3c\uff0c\u7d22\u5f15\u4ece0\u5f00\u59cb\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">second_row = array[1, :]<\/p>\n<p>print(second_row)  # \u8f93\u51fa: [4 5 6]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>\u8fd9\u79cd\u65b9\u5f0f\u4e0d\u4ec5\u7b80\u6d01\uff0c\u800c\u4e14\u5728\u5904\u7406\u5927\u578b\u6570\u636e\u65f6\u6548\u7387\u66f4\u9ad8\u3002<\/strong><\/p>\n<\/p>\n<p><h2>4\u3001\u5904\u7406\u8fb9\u754c\u6761\u4ef6<\/h2>\n<\/p>\n<p><p>\u4e0e\u5217\u8868\u64cd\u4f5c\u7c7b\u4f3c\uff0c\u5728\u4f7f\u7528NumPy\u6570\u7ec4\u7d22\u5f15\u65f6\uff0c\u4e5f\u9700\u8981\u5904\u7406\u8fb9\u754c\u6761\u4ef6\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">index = 1<\/p>\n<p>if 0 &lt;= index &lt; array.shape[0]:<\/p>\n<p>    row_data = array[index, :]<\/p>\n<p>    print(row_data)<\/p>\n<p>else:<\/p>\n<p>    print(&quot;\u7d22\u5f15\u8d85\u51fa\u8303\u56f4&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<h2><strong>\u4e09\u3001\u5176\u4ed6\u65b9\u6cd5\u548c\u6280\u5de7<\/strong><\/h2>\n<p><h2>1\u3001\u5207\u7247\u64cd\u4f5c<\/h2>\n<\/p>\n<p><p>\u9664\u4e86\u4f7f\u7528\u7d22\u5f15\u83b7\u53d6\u5355\u884c\u6570\u636e\u5916\uff0cNumPy\u8fd8\u652f\u6301\u5207\u7247\u64cd\u4f5c\uff0c\u53ef\u4ee5\u83b7\u53d6\u591a\u884c\u6570\u636e\u3002\u4f8b\u5982\uff0c\u8981\u83b7\u53d6\u524d\u4e24\u884c\u6570\u636e\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">first_two_rows = array[:2, :]<\/p>\n<p>print(first_two_rows)  # \u8f93\u51fa: [[1 2 3]<\/p>\n<p>                       #       [4 5 6]]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>2\u3001\u5e03\u5c14\u7d22\u5f15<\/h2>\n<\/p>\n<p><p>NumPy\u8fd8\u652f\u6301\u5e03\u5c14\u7d22\u5f15\uff0c\u53ef\u4ee5\u6839\u636e\u6761\u4ef6\u83b7\u53d6\u6ee1\u8db3\u6761\u4ef6\u7684\u884c\u6570\u636e\u3002\u4f8b\u5982\uff0c\u8981\u83b7\u53d6\u6240\u6709\u7b2c\u4e00\u5217\u5927\u4e8e2\u7684\u884c\u6570\u636e\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">filtered_rows = array[array[:, 0] &gt; 2, :]<\/p>\n<p>print(filtered_rows)  # \u8f93\u51fa: [[4 5 6]<\/p>\n<p>                      #       [7 8 9]]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>\u8fd9\u79cd\u65b9\u5f0f\u5728\u5904\u7406\u590d\u6742\u6761\u4ef6\u7b5b\u9009\u65f6\u975e\u5e38\u6709\u7528\u3002<\/strong><\/p>\n<\/p>\n<p><h2>3\u3001\u7ed3\u5408Pandas\u5e93<\/h2>\n<\/p>\n<p><p>\u5982\u679c\u4f60\u7684\u6570\u636e\u6765\u81eaCSV\u6587\u4ef6\u6216\u6570\u636e\u5e93\uff0cPandas\u5e93\u662f\u4e00\u4e2a\u66f4\u5f3a\u5927\u7684\u5de5\u5177\u3002Pandas\u63d0\u4f9b\u4e86DataFrame\u7ed3\u6784\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u8fdb\u884c\u5404\u79cd\u6570\u636e\u64cd\u4f5c\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<h2><strong>\u4eceCSV\u6587\u4ef6\u8bfb\u53d6\u6570\u636e<\/strong><\/h2>\n<p>df = pd.read_csv(&#39;data.csv&#39;)<\/p>\n<h2><strong>\u83b7\u53d6\u6307\u5b9a\u884c\u6570\u636e<\/strong><\/h2>\n<p>second_row = df.iloc[1]<\/p>\n<p>print(second_row)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<h2><strong>\u56db\u3001\u5b9e\u9645\u5e94\u7528\u573a\u666f<\/strong><\/h2>\n<p><h2>1\u3001\u6570\u636e\u5206\u6790<\/h2>\n<\/p>\n<p><p>\u5728\u6570\u636e\u5206\u6790\u8fc7\u7a0b\u4e2d\uff0c\u5e38\u5e38\u9700\u8981\u4ece\u4e8c\u7ef4\u6570\u7ec4\u4e2d\u83b7\u53d6\u7279\u5b9a\u884c\u7684\u6570\u636e\u8fdb\u884c\u7edf\u8ba1\u5206\u6790\u3002\u4f8b\u5982\uff0c\u8ba1\u7b97\u67d0\u4e00\u884c\u7684\u5747\u503c\u3001\u65b9\u5dee\u7b49\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<h2><strong>\u5047\u8bbe\u6709\u4e00\u4e2a\u4e8c\u7ef4\u6570\u7ec4<\/strong><\/h2>\n<p>data = np.array([<\/p>\n<p>    [1, 2, 3],<\/p>\n<p>    [4, 5, 6],<\/p>\n<p>    [7, 8, 9]<\/p>\n<p>])<\/p>\n<h2><strong>\u83b7\u53d6\u7b2c\u4e8c\u884c\u6570\u636e<\/strong><\/h2>\n<p>second_row = data[1, :]<\/p>\n<h2><strong>\u8ba1\u7b97\u5747\u503c\u548c\u65b9\u5dee<\/strong><\/h2>\n<p>mean = np.mean(second_row)<\/p>\n<p>variance = np.var(second_row)<\/p>\n<p>print(f&quot;\u5747\u503c: {mean}, \u65b9\u5dee: {variance}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>2\u3001<a href=\"https:\/\/docs.pingcode.com\/ask\/59192.html\" target=\"_blank\">\u673a\u5668\u5b66\u4e60<\/a><\/h2>\n<\/p>\n<p><p>\u5728\u673a\u5668\u5b66\u4e60\u4e2d\uff0c\u6570\u636e\u9884\u5904\u7406\u662f\u4e00\u4e2a\u5173\u952e\u6b65\u9aa4\u3002\u7ecf\u5e38\u9700\u8981\u4ece\u6570\u636e\u96c6\u4e2d\u63d0\u53d6\u7279\u5b9a\u884c\u7684\u6570\u636e\u8fdb\u884c\u8bad\u7ec3\u6216\u6d4b\u8bd5\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<p>from sklearn.model_selection import tr<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>n_test_split<\/p>\n<h2><strong>\u5047\u8bbe\u6709\u4e00\u4e2a\u6570\u636e\u96c6<\/strong><\/h2>\n<p>data = np.array([<\/p>\n<p>    [1, 2, 3],<\/p>\n<p>    [4, 5, 6],<\/p>\n<p>    [7, 8, 9],<\/p>\n<p>    [10, 11, 12]<\/p>\n<p>])<\/p>\n<h2><strong>\u5212\u5206\u8bad\u7ec3\u96c6\u548c\u6d4b\u8bd5\u96c6<\/strong><\/h2>\n<p>train_data, test_data = train_test_split(data, test_size=0.25)<\/p>\n<h2><strong>\u83b7\u53d6\u8bad\u7ec3\u96c6\u4e2d\u7684\u7b2c\u4e00\u884c\u6570\u636e<\/strong><\/h2>\n<p>first_train_row = train_data[0, :]<\/p>\n<p>print(first_train_row)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>3\u3001\u56fe\u50cf\u5904\u7406<\/h2>\n<\/p>\n<p><p>\u5728\u56fe\u50cf\u5904\u7406\u9886\u57df\uff0c\u56fe\u50cf\u901a\u5e38\u8868\u793a\u4e3a\u4e8c\u7ef4\u6570\u7ec4\uff08\u7070\u5ea6\u56fe\uff09\u6216\u4e09\u7ef4\u6570\u7ec4\uff08\u5f69\u8272\u56fe\uff09\u3002\u83b7\u53d6\u7279\u5b9a\u884c\u7684\u6570\u636e\u53ef\u4ee5\u7528\u4e8e\u56fe\u50cf\u7684\u88c1\u526a\u3001\u6ee4\u6ce2\u7b49\u64cd\u4f5c\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<p>import cv2<\/p>\n<h2><strong>\u8bfb\u53d6\u56fe\u50cf<\/strong><\/h2>\n<p>image = cv2.imread(&#39;image.jpg&#39;, cv2.IMREAD_GRAYSCALE)<\/p>\n<h2><strong>\u83b7\u53d6\u56fe\u50cf\u7684\u9ad8\u5ea6\u548c\u5bbd\u5ea6<\/strong><\/h2>\n<p>height, width = image.shape<\/p>\n<h2><strong>\u83b7\u53d6\u56fe\u50cf\u4e2d\u95f4\u7684\u4e00\u884c\u6570\u636e<\/strong><\/h2>\n<p>middle_row = image[height \/\/ 2, :]<\/p>\n<h2><strong>\u663e\u793a\u4e2d\u95f4\u884c\u6570\u636e\u7684\u76f4\u65b9\u56fe<\/strong><\/h2>\n<p>import matplotlib.pyplot as plt<\/p>\n<p>plt.hist(middle_row, bins=256, range=(0, 256))<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<h2><strong>\u4e94\u3001\u603b\u7ed3<\/strong><\/h2>\n<p><p>\u901a\u8fc7\u672c\u6587\uff0c\u6211\u4eec\u8be6\u7ec6\u4ecb\u7ecd\u4e86\u5728Python\u4e2d\u83b7\u53d6\u4e8c\u7ef4\u6570\u7ec4\u6307\u5b9a\u884c\u6570\u636e\u7684\u591a\u79cd\u65b9\u6cd5\u3002<strong>\u5305\u62ec\u57fa\u7840\u7684\u5217\u8868\u64cd\u4f5c\u3001NumPy\u5e93\u7684\u4f7f\u7528\u3001\u5207\u7247\u64cd\u4f5c\u3001\u5e03\u5c14\u7d22\u5f15\u4ee5\u53ca\u7ed3\u5408Pandas\u5e93\u7684\u4f7f\u7528\u3002<\/strong> \u5e76\u901a\u8fc7\u591a\u4e2a\u5b9e\u9645\u5e94\u7528\u573a\u666f\u5c55\u793a\u4e86\u8fd9\u4e9b\u65b9\u6cd5\u7684\u5177\u4f53\u5e94\u7528\u3002<\/p>\n<\/p>\n<p><p><strong>\u65e0\u8bba\u662f\u6570\u636e\u5206\u6790\u3001\u673a\u5668\u5b66\u4e60\u8fd8\u662f\u56fe\u50cf\u5904\u7406\uff0c\u638c\u63e1\u8fd9\u4e9b\u6280\u5de7\u90fd\u80fd\u5e2e\u52a9\u6211\u4eec\u9ad8\u6548\u5730\u5904\u7406\u548c\u5206\u6790\u6570\u636e\u3002<\/strong> \u5e0c\u671b\u672c\u6587\u80fd\u4e3a\u4f60\u63d0\u4f9b\u6709\u4ef7\u503c\u7684\u53c2\u8003\u548c\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\u4e00\u4e2a\u4e8c\u7ef4\u6570\u7ec4\u5e76\u83b7\u53d6\u6307\u5b9a\u884c\u7684\u6570\u636e\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u5d4c\u5957\u5217\u8868\u6765\u521b\u5efa\u4e00\u4e2a\u4e8c\u7ef4\u6570\u7ec4\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u5b9a\u4e49\u4e00\u4e2a\u5217\u8868\uff0c\u5176\u4e2d\u6bcf\u4e2a\u5b50\u5217\u8868\u4ee3\u8868\u4e8c\u7ef4\u6570\u7ec4\u7684\u4e00\u884c\u3002\u8981\u83b7\u53d6\u6307\u5b9a\u884c\u7684\u6570\u636e\uff0c\u53ea\u9700\u4f7f\u7528\u7d22\u5f15\u8bbf\u95ee\u8be5\u884c\u3002\u4f8b\u5982\uff0c<code>array[row_index]<\/code>\u53ef\u4ee5\u8fd4\u56de\u6307\u5b9a\u884c\u7684\u6240\u6709\u5143\u7d20\u3002<\/p>\n<p><strong>\u4f7f\u7528NumPy\u5e93\u53ef\u4ee5\u66f4\u65b9\u4fbf\u5730\u64cd\u4f5c\u4e8c\u7ef4\u6570\u7ec4\u5417\uff1f<\/strong><br \/>\u662f\u7684\uff0cNumPy\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u79d1\u5b66\u8ba1\u7b97\u5e93\uff0c\u975e\u5e38\u9002\u5408\u5904\u7406\u6570\u7ec4\u548c\u77e9\u9635\u64cd\u4f5c\u3002\u901a\u8fc7NumPy\uff0c\u60a8\u53ef\u4ee5\u8f7b\u677e\u521b\u5efa\u4e8c\u7ef4\u6570\u7ec4\uff0c\u5e76\u4f7f\u7528\u5207\u7247\u83b7\u53d6\u6307\u5b9a\u884c\u7684\u6570\u636e\u3002\u4f7f\u7528<code>numpy.array()<\/code>\u51fd\u6570\u521b\u5efa\u6570\u7ec4\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7<code>array[row_index]<\/code>\u76f4\u63a5\u8bbf\u95ee\u7279\u5b9a\u884c\uff0c\u64cd\u4f5c\u66f4\u52a0\u7b80\u6d01\u9ad8\u6548\u3002<\/p>\n<p><strong>\u5728\u5904\u7406\u5927\u578b\u4e8c\u7ef4\u6570\u7ec4\u65f6\uff0c\u6709\u54ea\u4e9b\u6027\u80fd\u4f18\u5316\u5efa\u8bae\uff1f<\/strong><br \/>\u5f53\u5904\u7406\u5927\u578b\u4e8c\u7ef4\u6570\u7ec4\u65f6\uff0c\u9009\u62e9\u5408\u9002\u7684\u6570\u636e\u7ed3\u6784\u975e\u5e38\u91cd\u8981\u3002\u4f7f\u7528NumPy\u800c\u975e\u4f20\u7edf\u7684\u5217\u8868\u53ef\u4ee5\u663e\u8457\u63d0\u9ad8\u6027\u80fd\uff0c\u56e0\u4e3aNumPy\u4f7f\u7528\u8fde\u7eed\u7684\u5185\u5b58\u5757\u5b58\u50a8\u6570\u636e\u5e76\u63d0\u4f9b\u4e86\u8bb8\u591a\u4f18\u5316\u7684\u6570\u5b66\u51fd\u6570\u3002\u6b64\u5916\uff0c\u5c3d\u91cf\u907f\u514d\u4f7f\u7528Python\u7684\u5faa\u73af\u7ed3\u6784\u6765\u904d\u5386\u6570\u7ec4\uff0c\u4f7f\u7528\u5411\u91cf\u5316\u64cd\u4f5c\u80fd\u591f\u63d0\u5347\u8fd0\u884c\u6548\u7387\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Python \u83b7\u53d6\u4e8c\u7ef4\u6570\u7ec4\u6307\u5b9a\u884c\u6570\u636e\u7684\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u5305\u62ec\u4f7f\u7528\u57fa\u7840\u7684\u5217\u8868\u64cd\u4f5c\u3001NumPy\u5e93\u7b49\u3002 \u5176\u4e2d\uff0cNumPy\u5e93 [&hellip;]","protected":false},"author":3,"featured_media":1142213,"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\/1142195"}],"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=1142195"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1142195\/revisions"}],"predecessor-version":[{"id":1142217,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1142195\/revisions\/1142217"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1142213"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1142195"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1142195"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1142195"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}