{"id":21291,"date":"2024-11-19T15:53:00","date_gmt":"2024-11-19T07:53:00","guid":{"rendered":"https:\/\/fwq.ai\/blog\/21291\/"},"modified":"2024-11-19T15:53:00","modified_gmt":"2024-11-19T07:53:00","slug":"vscode%e6%80%8e%e4%b9%88%e5%af%bc%e5%85%a5numpy","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/21291\/","title":{"rendered":"vscode\u600e\u4e48\u5bfc\u5165numpy"},"content":{"rendered":"<blockquote><p>\n  \u5728 vscode \u4e2d\u5bfc\u5165 numpy \u7684\u6b65\u9aa4\u5305\u62ec\uff1a\u4f7f\u7528 pip \u5b89\u88c5 numpy\u3002\u521b\u5efa\u4e00\u4e2a python \u6587\u4ef6\u3002\u4f7f\u7528 import numpy as np \u5bfc\u5165 numpy\u3002\u5982\u9700\u5bfc\u5165\u7279\u5b9a\u7684\u51fd\u6570\u6216\u7c7b\uff0c\u53ef\u4f7f\u7528 from numpy import \u6240\u9700\u5143\u7d20\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/15\/2024051506541999525.jpg\" class=\"aligncenter\" title=\"vscode\u600e\u4e48\u5bfc\u5165numpy\u63d2\u56fe\" alt=\"vscode\u600e\u4e48\u5bfc\u5165numpy\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5728 Visual Studio Code \u4e2d\u5bfc\u5165 NumPy<\/strong><\/p>\n<p>\u5728 Visual Studio Code (VSCode) \u4e2d\u5bfc\u5165 NumPy \u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u8981\u4ee5\u4e0b\u51e0\u4e2a\u6b65\u9aa4\uff1a<\/p>\n<p><strong>1. \u5b89\u88c5 NumPy\uff1a<\/strong><\/p>\n<p>\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u6216\u7ec8\u7aef\u4e2d\u4f7f\u7528 pip \u5b89\u88c5 NumPy\uff1a<\/p>\n<pre>pip install numpy<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>2. \u521b\u5efa Python \u6587\u4ef6\uff1a<\/strong><\/p>\n<p>\u5728 VSCode \u4e2d\u521b\u5efa\u4e00\u4e2a\u65b0\u7684 Python \u6587\u4ef6\uff0c\u4f8b\u5982 filename.py\u3002<\/p>\n<p><strong>3. \u5bfc\u5165 NumPy\uff1a<\/strong><\/p>\n<p>\u5728 Python \u6587\u4ef6\u4e2d\uff0c\u4f7f\u7528 import numpy as np \u5bfc\u5165 NumPy\u3002\u8fd9\u5c06\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a np \u7684\u522b\u540d\uff0c\u7528\u4e8e\u8bbf\u95ee NumPy \u51fd\u6570\u548c\u7c7b\u3002<\/p>\n<p>\u4e0b\u9762\u662f\u4e00\u4e2a\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<pre>import numpy as np\n\n# \u521b\u5efa\u4e00\u4e2a NumPy \u6570\u7ec4\narray = np.array([1, 2, 3, 4, 5])\n\n# \u4f7f\u7528 NumPy \u51fd\u6570\u5bf9\u6570\u7ec4\u8fdb\u884c\u64cd\u4f5c\nprint(np.sum(array))  # \u8f93\u51fa\uff1a15<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>4. \u5bfc\u5165\u7279\u5b9a\u7684 NumPy \u51fd\u6570\u6216\u7c7b\uff1a<\/strong><\/p>\n<p>\u9664\u4e86\u5bfc\u5165\u6574\u4e2a NumPy \u6a21\u5757\u5916\uff0c\u8fd8\u53ef\u4ee5\u53ea\u5bfc\u5165\u6240\u9700\u7684\u529f\u80fd\u6216\u7c7b\u3002\u4f8b\u5982\uff0c\u8981\u5bfc\u5165 ndarray \u7c7b\uff0c\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<pre>from numpy import ndarray<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u63d0\u793a\uff1a<\/strong><\/p>\n<ul>\n<li>\u786e\u4fdd\u5df2\u5b89\u88c5\u6700\u65b0\u7248\u672c\u7684 pip \u548c Python \u89e3\u91ca\u5668\u3002<\/li>\n<li>\u68c0\u67e5 NumPy \u662f\u5426\u5df2\u6b63\u786e\u5b89\u88c5\uff0c\u65b9\u6cd5\u662f\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u6216\u7ec8\u7aef\u4e2d\u8f93\u5165 pip show numpy\u3002<\/li>\n<li>\u5728\u5bfc\u5165 NumPy \u4e4b\u524d\uff0c\u786e\u4fdd\u5df2\u5728\u5de5\u4f5c\u7a7a\u95f4\u4e2d\u521b\u5efa Python \u6587\u4ef6\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u5bfc\u5165numpy\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 vscode \u4e2d\u5bfc\u5165 numpy \u7684\u6b65\u9aa4\u5305\u62ec\uff1a\u4f7f\u7528 pip \u5b89\u88c5 numpy\u3002\u521b\u5efa\u4e00\u4e2a python \u6587\u4ef6\u3002\u4f7f\u7528 import numpy as np \u5bfc\u5165 numpy\u3002\u5982\u9700\u5bfc\u5165\u7279\u5b9a\u7684\u51fd\u6570\u6216\u7c7b\uff0c\u53ef\u4f7f\u7528 from numpy import \u6240\u9700\u5143\u7d20\u3002 \u5982\u4f55\u5728 Visual Studio Code \u4e2d\u5bfc\u5165 NumPy \u5728 Visual Studio Code (VSCode) \u4e2d\u5bfc\u5165 NumPy \u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u8981\u4ee5\u4e0b\u51e0\u4e2a\u6b65\u9aa4\uff1a 1. \u5b89\u88c5 NumPy\uff1a \u5728\u547d\u4ee4\u63d0\u793a\u7b26\u6216\u7ec8\u7aef\u4e2d\u4f7f\u7528 pip \u5b89\u88c5 NumPy\uff1a pip install numpy \u767b\u5f55\u540e\u590d\u5236 2. \u521b\u5efa Python \u6587\u4ef6\uff1a \u5728 VSCode \u4e2d\u521b\u5efa\u4e00\u4e2a\u65b0\u7684 Python \u6587\u4ef6\uff0c\u4f8b\u5982 filename.py\u3002 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-21291","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/21291","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=21291"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/21291\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=21291"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=21291"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=21291"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}