{"id":994884,"date":"2024-12-27T08:59:22","date_gmt":"2024-12-27T00:59:22","guid":{"rendered":""},"modified":"2024-12-27T08:59:24","modified_gmt":"2024-12-27T00:59:24","slug":"python%e4%b8%ad%e5%a6%82%e4%bd%95%e8%a1%a8%e7%a4%ba%e5%90%91%e9%87%8f","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/994884.html","title":{"rendered":"python\u4e2d\u5982\u4f55\u8868\u793a\u5411\u91cf"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25071700\/782844ec-97bc-4b06-955f-df84e0072db9.webp\" alt=\"python\u4e2d\u5982\u4f55\u8868\u793a\u5411\u91cf\" \/><\/p>\n<p><p> \u5728Python\u4e2d\u8868\u793a\u5411\u91cf\u7684\u65b9\u5f0f\u6709\u591a\u79cd\uff0c<strong>\u5e38\u7528\u7684\u65b9\u6cd5\u5305\u62ec\u4f7f\u7528\u5217\u8868\u3001\u5143\u7ec4\u3001NumPy\u6570\u7ec4\u3001Pandas\u6570\u636e\u7ed3\u6784<\/strong>\u3002\u5176\u4e2d\uff0c\u6700\u5e38\u7528\u4e14\u529f\u80fd\u5f3a\u5927\u7684\u65b9\u5f0f\u662f\u4f7f\u7528NumPy\u5e93\uff0c\u56e0\u4e3a\u5b83\u63d0\u4f9b\u4e86\u4e13\u95e8\u4e3a\u79d1\u5b66\u8ba1\u7b97\u8bbe\u8ba1\u7684\u6570\u7ec4\u5bf9\u8c61\uff0c\u652f\u6301\u5411\u91cf\u548c\u77e9\u9635\u64cd\u4f5c\u3002<strong>NumPy\u6570\u7ec4\u4e0d\u4ec5\u652f\u6301\u57fa\u672c\u7684\u5411\u91cf\u8fd0\u7b97\uff0c\u8fd8\u63d0\u4f9b\u4e86\u8bb8\u591a\u9ad8\u7ea7\u529f\u80fd\uff0c\u5982\u7ebf\u6027\u4ee3\u6570\u3001\u5085\u91cc\u53f6\u53d8\u6362\u7b49<\/strong>\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u8fd9\u4e9b\u65b9\u6cd5\u53ca\u5176\u4f18\u7f3a\u70b9\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u4f7f\u7528\u5217\u8868\u8868\u793a\u5411\u91cf<\/p>\n<\/p>\n<p><p>\u5728Python\u4e2d\uff0c\u6700\u7b80\u5355\u7684\u65b9\u5f0f\u662f\u4f7f\u7528\u5217\u8868\u6765\u8868\u793a\u5411\u91cf\u3002\u5217\u8868\u662fPython\u5185\u7f6e\u7684\u6570\u636e\u7ed3\u6784\uff0c\u652f\u6301\u5b58\u50a8\u4e00\u7ec4\u6709\u5e8f\u5143\u7d20\uff0c\u5e76\u4e14\u80fd\u591f\u52a8\u6001\u8c03\u6574\u5927\u5c0f\u3002<\/p>\n<\/p>\n<ol>\n<li><strong>\u57fa\u672c\u7528\u6cd5<\/strong><\/li>\n<\/ol>\n<p><p>\u5217\u8868\u662f\u4e00\u79cd\u7075\u6d3b\u7684\u6570\u636e\u7ed3\u6784\uff0c\u53ef\u4ee5\u5b58\u50a8\u4e0d\u540c\u7c7b\u578b\u7684\u6570\u636e\u3002\u5728\u8868\u793a\u5411\u91cf\u65f6\uff0c\u901a\u5e38\u4f7f\u7528\u4e00\u7ef4\u5217\u8868\uff0c\u5176\u4e2d\u6bcf\u4e2a\u5143\u7d20\u4ee3\u8868\u5411\u91cf\u7684\u4e00\u4e2a\u5206\u91cf\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">vector = [1, 2, 3]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e2a\u5217\u8868\u8868\u793a\u4e00\u4e2a\u4e09\u7ef4\u5411\u91cf\uff0c\u5176\u4e2d1\u30012\u548c3\u662f\u5411\u91cf\u7684\u5206\u91cf\u3002\u5217\u8868\u7684\u4f18\u70b9\u662f\u7b80\u5355\u6613\u7528\uff0c\u4f46\u5728\u8fdb\u884c\u5411\u91cf\u8fd0\u7b97\u65f6\u9700\u8981\u7f16\u5199\u989d\u5916\u7684\u4ee3\u7801\uff0c\u56e0\u4e3a\u5217\u8868\u672c\u8eab\u4e0d\u652f\u6301\u5411\u91cf\u8fd0\u7b97\u3002<\/p>\n<\/p>\n<ol start=\"2\">\n<li><strong>\u5411\u91cf\u8fd0\u7b97<\/strong><\/li>\n<\/ol>\n<p><p>\u5c3d\u7ba1\u5217\u8868\u4e0d\u652f\u6301\u76f4\u63a5\u7684\u5411\u91cf\u8fd0\u7b97\uff0c\u4f46\u53ef\u4ee5\u901a\u8fc7\u5217\u8868\u63a8\u5bfc\u5f0f\u6216\u4f7f\u7528Python\u7684\u6807\u51c6\u5e93\u8fdb\u884c\u6a21\u62df\u3002\u4f8b\u5982\uff0c\u4e24\u4e2a\u5411\u91cf\u7684\u52a0\u6cd5\u53ef\u4ee5\u8fd9\u6837\u5b9e\u73b0\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">vector1 = [1, 2, 3]<\/p>\n<p>vector2 = [4, 5, 6]<\/p>\n<p>vector_sum = [v1 + v2 for v1, v2 in zip(vector1, vector2)]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u79cd\u65b9\u5f0f\u867d\u7136\u53ef\u884c\uff0c\u4f46\u5728\u5904\u7406\u5927\u89c4\u6a21\u6570\u636e\u6216\u590d\u6742\u8fd0\u7b97\u65f6\u6548\u7387\u8f83\u4f4e\u3002<\/p>\n<\/p>\n<p><p>\u4e8c\u3001\u4f7f\u7528\u5143\u7ec4\u8868\u793a\u5411\u91cf<\/p>\n<\/p>\n<p><p>\u5143\u7ec4\u4e0e\u5217\u8868\u7c7b\u4f3c\uff0c\u4e5f\u662fPython\u5185\u7f6e\u7684\u6570\u636e\u7ed3\u6784\uff0c\u4f46\u5143\u7ec4\u662f\u4e0d\u53ef\u53d8\u7684\u3002\u8fd9\u610f\u5473\u7740\u4e00\u65e6\u521b\u5efa\u4e86\u4e00\u4e2a\u5143\u7ec4\uff0c\u5176\u5185\u5bb9\u4e0d\u80fd\u66f4\u6539\u3002<\/p>\n<\/p>\n<ol>\n<li><strong>\u57fa\u672c\u7528\u6cd5<\/strong><\/li>\n<\/ol>\n<p><p>\u4f7f\u7528\u5143\u7ec4\u8868\u793a\u5411\u91cf\u7684\u65b9\u5f0f\u4e0e\u5217\u8868\u7c7b\u4f3c\uff0c\u4f46\u7531\u4e8e\u5143\u7ec4\u662f\u4e0d\u53ef\u53d8\u7684\uff0c\u56e0\u6b64\u5728\u67d0\u4e9b\u573a\u5408\u4e0b\u4f7f\u7528\u5143\u7ec4\u53ef\u4ee5\u63d0\u9ad8\u4ee3\u7801\u7684\u5b89\u5168\u6027\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">vector = (1, 2, 3)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li><strong>\u5411\u91cf\u8fd0\u7b97<\/strong><\/li>\n<\/ol>\n<p><p>\u4e0e\u5217\u8868\u7c7b\u4f3c\uff0c\u53ef\u4ee5\u901a\u8fc7\u89e3\u5305\u548c\u6807\u51c6\u5e93\u51fd\u6570\u6765\u5b9e\u73b0\u5411\u91cf\u8fd0\u7b97\uff0c\u4f46\u4e5f\u9700\u8981\u989d\u5916\u7684\u4ee3\u7801\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">vector1 = (1, 2, 3)<\/p>\n<p>vector2 = (4, 5, 6)<\/p>\n<p>vector_sum = tuple(v1 + v2 for v1, v2 in zip(vector1, vector2))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5143\u7ec4\u7684\u4e3b\u8981\u4f18\u52bf\u662f\u4e0d\u53ef\u53d8\u6027\uff0c\u8fd9\u5728\u9700\u8981\u9632\u6b62\u6570\u636e\u88ab\u610f\u5916\u4fee\u6539\u65f6\u7279\u522b\u6709\u7528\u3002<\/p>\n<\/p>\n<p><p>\u4e09\u3001\u4f7f\u7528NumPy\u6570\u7ec4\u8868\u793a\u5411\u91cf<\/p>\n<\/p>\n<p><p>NumPy\u662fPython\u7684\u4e00\u4e2a\u5f00\u6e90\u5e93\uff0c\u4e13\u4e3a\u79d1\u5b66\u8ba1\u7b97\u8bbe\u8ba1\uff0c\u63d0\u4f9b\u4e86\u9ad8\u6548\u7684\u591a\u7ef4\u6570\u7ec4\u5bf9\u8c61\u4ee5\u53ca\u4e30\u5bcc\u7684\u6570\u5b66\u51fd\u6570\u3002<\/p>\n<\/p>\n<ol>\n<li><strong>\u57fa\u672c\u7528\u6cd5<\/strong><\/li>\n<\/ol>\n<p><p>NumPy\u7684\u6838\u5fc3\u662fndarray\u5bf9\u8c61\uff0c\u5b83\u662f\u4e00\u4e2a\u591a\u7ef4\u6570\u7ec4\u3002\u4f7f\u7528NumPy\u6570\u7ec4\u8868\u793a\u5411\u91cf\u7684\u65b9\u5f0f\u975e\u5e38\u76f4\u63a5\uff0c\u5e76\u4e14\u5b83\u652f\u6301\u77e2\u91cf\u5316\u8fd0\u7b97\uff0c\u5373\u5bf9\u6570\u7ec4\u7684\u64cd\u4f5c\u53ef\u4ee5\u4e00\u6b21\u6027\u5e94\u7528\u4e8e\u6240\u6709\u5143\u7d20\u3002\u793a\u4f8b\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<p>vector = np.array([1, 2, 3])<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li><strong>\u5411\u91cf\u8fd0\u7b97<\/strong><\/li>\n<\/ol>\n<p><p>NumPy\u6570\u7ec4\u652f\u6301\u76f4\u63a5\u7684\u5411\u91cf\u8fd0\u7b97\uff0c\u5982\u52a0\u6cd5\u3001\u51cf\u6cd5\u3001\u6807\u91cf\u4e58\u6cd5\u7b49\uff0c\u8fd9\u4f7f\u5f97\u4ee3\u7801\u66f4\u52a0\u7b80\u6d01\u548c\u9ad8\u6548\u3002\u4f8b\u5982\uff0c\u4e24\u4e2a\u5411\u91cf\u7684\u52a0\u6cd5\u53ef\u4ee5\u76f4\u63a5\u5199\u6210\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">vector1 = np.array([1, 2, 3])<\/p>\n<p>vector2 = np.array([4, 5, 6])<\/p>\n<p>vector_sum = vector1 + vector2<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>NumPy\u7684\u4f18\u52bf\u5728\u4e8e\u5176\u9ad8\u6548\u7684\u8fd0\u7b97\u6027\u80fd\u548c\u4e30\u5bcc\u7684\u529f\u80fd\uff0c\u7279\u522b\u662f\u5728\u5904\u7406\u5927\u89c4\u6a21\u6570\u636e\u65f6\uff0cNumPy\u7684\u6027\u80fd\u8fdc\u8fdc\u8d85\u8fc7\u7eafPython\u7684\u5b9e\u73b0\u3002<\/p>\n<\/p>\n<p><p>\u56db\u3001\u4f7f\u7528Pandas\u8868\u793a\u5411\u91cf<\/p>\n<\/p>\n<p><p>Pandas\u662fPython\u7684\u6570\u636e\u5206\u6790\u5e93\uff0c\u63d0\u4f9b\u4e86\u6570\u636e\u6846\u548c\u5e8f\u5217\u5bf9\u8c61\uff0c\u53ef\u4ee5\u7528\u4e8e\u6570\u636e\u7684\u9ad8\u6548\u5904\u7406\u548c\u5206\u6790\u3002<\/p>\n<\/p>\n<ol>\n<li><strong>\u57fa\u672c\u7528\u6cd5<\/strong><\/li>\n<\/ol>\n<p><p>\u5728Pandas\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528Series\u5bf9\u8c61\u8868\u793a\u5411\u91cf\u3002Series\u662f\u5e26\u6709\u6807\u7b7e\u7684\u4e00\u7ef4\u6570\u7ec4\uff0c\u7c7b\u4f3c\u4e8eNumPy\u7684\u6570\u7ec4\uff0c\u4f46\u63d0\u4f9b\u4e86\u66f4\u4e30\u5bcc\u7684\u529f\u80fd\u548c\u65b9\u6cd5\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<p>vector = pd.Series([1, 2, 3])<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li><strong>\u5411\u91cf\u8fd0\u7b97<\/strong><\/li>\n<\/ol>\n<p><p>Pandas\u7684Series\u5bf9\u8c61\u4e5f\u652f\u6301\u77e2\u91cf\u5316\u8fd0\u7b97\uff0c\u5e76\u4e14\u53ef\u4ee5\u4e0eNumPy\u6570\u7ec4\u65e0\u7f1d\u96c6\u6210\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">vector1 = pd.Series([1, 2, 3])<\/p>\n<p>vector2 = pd.Series([4, 5, 6])<\/p>\n<p>vector_sum = vector1 + vector2<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>Pandas\u7684\u4f18\u52bf\u5728\u4e8e\u5176\u5f3a\u5927\u7684\u6570\u636e\u5904\u7406\u80fd\u529b\uff0c\u7279\u522b\u662f\u5728\u9700\u8981\u5bf9\u6570\u636e\u8fdb\u884c\u590d\u6742\u5206\u6790\u65f6\uff0cPandas\u63d0\u4f9b\u4e86\u975e\u5e38\u4e30\u5bcc\u7684\u5de5\u5177\u548c\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><p>\u4e94\u3001\u4f7f\u7528SciPy\u5e93\u8fdb\u884c\u9ad8\u7ea7\u5411\u91cf\u64cd\u4f5c<\/p>\n<\/p>\n<p><p>SciPy\u662f\u4e00\u4e2a\u57fa\u4e8eNumPy\u7684\u5f00\u653e\u6e90\u4ee3\u7801Python\u5e93\uff0c\u9002\u7528\u4e8e\u6570\u5b66\u3001\u79d1\u5b66\u548c\u5de5\u7a0b\u9886\u57df\u3002SciPy\u6269\u5c55\u4e86NumPy\u7684\u529f\u80fd\uff0c\u63d0\u4f9b\u4e86\u8bb8\u591a\u9ad8\u7ea7\u7684\u6570\u5b66\u3001\u79d1\u5b66\u548c\u5de5\u7a0b\u51fd\u6570\u3002<\/p>\n<\/p>\n<ol>\n<li><strong>\u7ebf\u6027\u4ee3\u6570<\/strong><\/li>\n<\/ol>\n<p><p>SciPy\u7684\u7ebf\u6027\u4ee3\u6570\u6a21\u5757\u63d0\u4f9b\u4e86\u8bb8\u591a\u9ad8\u7ea7\u7684\u7ebf\u6027\u4ee3\u6570\u64cd\u4f5c\uff0c\u5982\u6c42\u89e3\u7ebf\u6027\u65b9\u7a0b\u7ec4\u3001\u7279\u5f81\u503c\u5206\u89e3\u3001\u5947\u5f02\u503c\u5206\u89e3\u7b49\u3002\u4f8b\u5982\uff0c\u4f7f\u7528SciPy\u6c42\u89e3\u7ebf\u6027\u65b9\u7a0b\u7ec4\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u4ee3\u7801\u5b9e\u73b0\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from scipy.linalg import solve<\/p>\n<p>A = np.array([[3, 1], [1, 2]])<\/p>\n<p>b = np.array([9, 8])<\/p>\n<p>x = solve(A, b)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li><strong>\u4f18\u5316<\/strong><\/li>\n<\/ol>\n<p><p>SciPy\u63d0\u4f9b\u4e86\u4f18\u5316\u6a21\u5757\uff0c\u53ef\u4ee5\u7528\u4e8e\u89e3\u51b3\u5404\u79cd\u4f18\u5316\u95ee\u9898\uff0c\u5982\u6700\u5c0f\u5316\u51fd\u6570\u3001\u66f2\u7ebf\u62df\u5408\u7b49\u3002\u4f8b\u5982\uff0c\u6c42\u89e3\u4e00\u4e2a\u7b80\u5355\u7684\u4f18\u5316\u95ee\u9898\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from scipy.optimize import minimize<\/p>\n<p>def objective_function(x):<\/p>\n<p>    return x2 + x + 2<\/p>\n<p>result = minimize(objective_function, x0=0)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u79d1\u5b66\u8ba1\u7b97\u4e2d\uff0cSciPy\u548cNumPy\u901a\u5e38\u7ed3\u5408\u4f7f\u7528\uff0c\u4ee5\u5145\u5206\u53d1\u6325\u5176\u5f3a\u5927\u7684\u6570\u636e\u5904\u7406\u548c\u6570\u5b66\u8ba1\u7b97\u80fd\u529b\u3002<\/p>\n<\/p>\n<p><p>\u603b\u7ed3<\/p>\n<\/p>\n<p><p>\u5728Python\u4e2d\u8868\u793a\u5411\u91cf\u7684\u65b9\u6cd5\u6709\u591a\u79cd\u9009\u62e9\uff0c\u5177\u4f53\u9009\u62e9\u53d6\u51b3\u4e8e\u5e94\u7528\u573a\u666f\u548c\u6027\u80fd\u9700\u6c42\u3002\u5bf9\u4e8e\u7b80\u5355\u7684\u5e94\u7528\uff0c\u5217\u8868\u548c\u5143\u7ec4\u662f\u5feb\u901f\u4e14\u6613\u4e8e\u4f7f\u7528\u7684\u9009\u62e9\uff1b\u5bf9\u4e8e\u9700\u8981\u9ad8\u6548\u6570\u503c\u8ba1\u7b97\u7684\u573a\u5408\uff0cNumPy\u662f\u6700\u5e38\u7528\u7684\u5de5\u5177\uff1b\u800c\u5728\u6570\u636e\u5206\u6790\u4e2d\uff0cPandas\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u6570\u636e\u64cd\u4f5c\u529f\u80fd\u3002\u5982\u679c\u9700\u8981\u8fdb\u884c\u590d\u6742\u7684\u6570\u5b66\u8fd0\u7b97\uff0cSciPy\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u9ad8\u7ea7\u51fd\u6570\u3002\u6839\u636e\u4e0d\u540c\u7684\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u5de5\u5177\uff0c\u53ef\u4ee5\u63d0\u9ad8\u4ee3\u7801\u7684\u6548\u7387\u548c\u53ef\u8bfb\u6027\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5728Python\u4e2d\uff0c\u5982\u4f55\u521b\u5efa\u4e00\u4e2a\u5411\u91cf\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u5217\u8868\u6216\u5143\u7ec4\u6765\u8868\u793a\u5411\u91cf\uff0c\u4f8b\u5982\uff1a<code>vector = [1, 2, 3]<\/code> \u6216 <code>vector = (1, 2, 3)<\/code>\u3002\u6b64\u5916\uff0c\u4f7f\u7528NumPy\u5e93\u53ef\u4ee5\u66f4\u65b9\u4fbf\u5730\u521b\u5efa\u5411\u91cf\uff0c\u793a\u4f8b\u4ee3\u7801\u4e3a <code>import numpy as np<\/code> \u548c <code>vector = np.array([1, 2, 3])<\/code>\uff0c\u8fd9\u6837\u4e0d\u4ec5\u53ef\u4ee5\u8868\u793a\u5411\u91cf\uff0c\u8fd8\u80fd\u5229\u7528NumPy\u63d0\u4f9b\u7684\u5f3a\u5927\u6570\u5b66\u8fd0\u7b97\u529f\u80fd\u3002<\/p>\n<p><strong>Python\u4e2d\u5411\u91cf\u7684\u5e38\u89c1\u64cd\u4f5c\u6709\u54ea\u4e9b\uff1f<\/strong><br \/>Python\u4e2d\u5bf9\u5411\u91cf\u7684\u5e38\u89c1\u64cd\u4f5c\u5305\u62ec\u52a0\u6cd5\u3001\u51cf\u6cd5\u3001\u70b9\u79ef\u3001\u53c9\u79ef\u7b49\u3002\u5982\u679c\u4f7f\u7528NumPy\u5e93\uff0c\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\u5185\u7f6e\u51fd\u6570\u8fdb\u884c\u8fd9\u4e9b\u64cd\u4f5c\u3002\u4f8b\u5982\uff0c\u4e24\u4e2a\u5411\u91cf\u76f8\u52a0\u53ef\u4ee5\u7528 <code>np.add(vector1, vector2)<\/code> \u5b9e\u73b0\uff0c\u800c\u70b9\u79ef\u53ef\u4ee5\u7528 <code>np.dot(vector1, vector2)<\/code> \u5b8c\u6210\u3002\u8fd9\u4e9b\u64cd\u4f5c\u7b80\u5316\u4e86\u5411\u91cf\u8fd0\u7b97\u5e76\u63d0\u9ad8\u4e86\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728Python\u4e2d\u53ef\u89c6\u5316\u5411\u91cf\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528Matplotlib\u5e93\u6765\u53ef\u89c6\u5316\u5411\u91cf\u3002\u901a\u8fc7\u7ed8\u5236\u7bad\u5934\u6216\u7ebf\u6bb5\u6765\u8868\u793a\u5411\u91cf\uff0c\u53ef\u4ee5\u4f7f\u7528 <code>plt.quiver()<\/code> \u51fd\u6570\u6765\u7ed8\u5236\u3002\u4f8b\u5982\uff0c<code>plt.quiver(0, 0, vector[0], vector[1], angles=&#39;xy&#39;, scale_units=&#39;xy&#39;, scale=1)<\/code> \u53ef\u4ee5\u5c06\u4e00\u4e2a\u4e8c\u7ef4\u5411\u91cf\u4ece\u539f\u70b9\u7ed8\u5236\u51fa\u6765\u3002\u8fd9\u6837\u53ef\u4ee5\u76f4\u89c2\u5730\u5c55\u793a\u5411\u91cf\u7684\u65b9\u5411\u548c\u5927\u5c0f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python\u4e2d\u8868\u793a\u5411\u91cf\u7684\u65b9\u5f0f\u6709\u591a\u79cd\uff0c\u5e38\u7528\u7684\u65b9\u6cd5\u5305\u62ec\u4f7f\u7528\u5217\u8868\u3001\u5143\u7ec4\u3001NumPy\u6570\u7ec4\u3001Pandas\u6570\u636e\u7ed3\u6784\u3002\u5176\u4e2d [&hellip;]","protected":false},"author":3,"featured_media":994901,"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\/994884"}],"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=994884"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/994884\/revisions"}],"predecessor-version":[{"id":994903,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/994884\/revisions\/994903"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/994901"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=994884"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=994884"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=994884"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}