{"id":970166,"date":"2024-12-27T05:23:37","date_gmt":"2024-12-26T21:23:37","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/970166.html"},"modified":"2024-12-27T05:23:39","modified_gmt":"2024-12-26T21:23:39","slug":"python%e5%a6%82%e4%bd%95%e6%9f%a5%e7%9c%8b%e6%9f%90%e4%b8%aa%e5%ba%93","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/970166.html","title":{"rendered":"python\u5982\u4f55\u67e5\u770b\u67d0\u4e2a\u5e93"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24184111\/2b722b8a-3692-43f5-b881-6dca94f1702b.webp\" alt=\"python\u5982\u4f55\u67e5\u770b\u67d0\u4e2a\u5e93\" \/><\/p>\n<p><p> <strong>\u5728Python\u4e2d\u67e5\u770b\u67d0\u4e2a\u5e93\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u65b9\u5f0f\u5b9e\u73b0\uff0c\u5305\u62ec\u4f7f\u7528<code>pip<\/code>\u3001<code>conda<\/code>\u547d\u4ee4\u67e5\u770b\u5df2\u5b89\u88c5\u7684\u5e93\u53ca\u5176\u7248\u672c\uff0c\u4f7f\u7528<code>help()<\/code>\u51fd\u6570\u67e5\u770b\u5e93\u7684\u6587\u6863\uff0c\u4ee5\u53ca\u4f7f\u7528<code>dir()<\/code>\u51fd\u6570\u67e5\u770b\u5e93\u4e2d\u7684\u6a21\u5757\u548c\u65b9\u6cd5\u3002\u4f7f\u7528<code>pip list<\/code>\u547d\u4ee4\u53ef\u4ee5\u5217\u51fa\u6240\u6709\u5df2\u5b89\u88c5\u7684\u5e93\u53ca\u5176\u7248\u672c\uff0c\u7528<code>help(\u5e93\u540d)<\/code>\u53ef\u4ee5\u83b7\u53d6\u8be5\u5e93\u7684\u8be6\u7ec6\u6587\u6863\uff0c<code>dir(\u5e93\u540d)<\/code>\u53ef\u4ee5\u67e5\u770b\u5e93\u4e2d\u6240\u6709\u53ef\u7528\u7684\u6a21\u5757\u548c\u51fd\u6570\u3002<\/strong>\u4e0b\u9762\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528\u8fd9\u4e9b\u65b9\u6cd5\u6765\u67e5\u770bPython\u4e2d\u7684\u5e93\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u4f7f\u7528Pip\u67e5\u770b\u5df2\u5b89\u88c5\u7684\u5e93<\/p>\n<\/p>\n<p><p>\u4f7f\u7528<code>pip<\/code>\u547d\u4ee4\u53ef\u4ee5\u65b9\u4fbf\u5730\u67e5\u770bPython\u4e2d\u5df2\u5b89\u88c5\u7684\u5e93\u53ca\u5176\u7248\u672c\u4fe1\u606f\u3002<code>pip<\/code>\u662fPython\u7684\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u5e38\u7528\u4e8e\u5b89\u88c5\u548c\u7ba1\u7406Python\u5305\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u67e5\u770b\u6240\u6709\u5df2\u5b89\u88c5\u7684\u5e93<\/strong><\/p>\n<\/p>\n<p><p>\u8981\u67e5\u770b\u7cfb\u7edf\u4e2d\u6240\u6709\u5df2\u5b89\u88c5\u7684Python\u5e93\uff0c\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip list<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u8f93\u51fa\u4e00\u4e2a\u5df2\u5b89\u88c5\u5e93\u7684\u5217\u8868\uff0c\u5305\u62ec\u5e93\u540d\u548c\u7248\u672c\u53f7\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u67e5\u770b\u7279\u5b9a\u5e93\u7684\u8be6\u7ec6\u4fe1\u606f<\/strong><\/p>\n<\/p>\n<p><p>\u5982\u679c\u60f3\u67e5\u770b\u67d0\u4e2a\u7279\u5b9a\u5e93\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u53ef\u4ee5\u4f7f\u7528<code>pip show<\/code>\u547d\u4ee4\u3002\u4f8b\u5982\uff0c\u8981\u67e5\u770b<code>numpy<\/code>\u5e93\u7684\u4fe1\u606f\uff0c\u53ef\u4ee5\u8f93\u5165\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip show numpy<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8be5\u547d\u4ee4\u5c06\u663e\u793a\u5e93\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u5305\u62ec\u7248\u672c\u3001\u5b89\u88c5\u4f4d\u7f6e\u3001\u4f9d\u8d56\u5173\u7cfb\u7b49\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u68c0\u67e5\u5e93\u7684\u66f4\u65b0<\/strong><\/p>\n<\/p>\n<p><p>\u53ef\u4ee5\u4f7f\u7528<code>pip list --outdated<\/code>\u547d\u4ee4\u6765\u68c0\u67e5\u54ea\u4e9b\u5e93\u6709\u66f4\u65b0\u7248\u672c\u53ef\u7528\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip list --outdated<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u5217\u51fa\u6240\u6709\u53ef\u4ee5\u66f4\u65b0\u7684\u5e93\u53ca\u5176\u5f53\u524d\u7248\u672c\u548c\u6700\u65b0\u7248\u672c\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e8c\u3001\u4f7f\u7528Conda\u67e5\u770b\u5df2\u5b89\u88c5\u7684\u5e93<\/p>\n<\/p>\n<p><p>\u5bf9\u4e8e\u4f7f\u7528Anaconda\u7684\u7528\u6237\uff0c\u53ef\u4ee5\u4f7f\u7528<code>conda<\/code>\u547d\u4ee4\u6765\u7ba1\u7406\u548c\u67e5\u770bPython\u5e93\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u67e5\u770b\u6240\u6709\u5df2\u5b89\u88c5\u7684\u5e93<\/strong><\/p>\n<\/p>\n<p><p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b\u6240\u6709\u5df2\u5b89\u88c5\u7684\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda list<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u663e\u793a\u4e00\u4e2a\u4e0e<code>pip list<\/code>\u7c7b\u4f3c\u7684\u5df2\u5b89\u88c5\u5e93\u5217\u8868\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u67e5\u770b\u7279\u5b9a\u5e93\u7684\u8be6\u7ec6\u4fe1\u606f<\/strong><\/p>\n<\/p>\n<p><p>\u4e0e<code>pip<\/code>\u7c7b\u4f3c\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b\u7279\u5b9a\u5e93\u7684\u4fe1\u606f\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda list numpy<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u663e\u793a\u5173\u4e8e<code>numpy<\/code>\u5e93\u7684\u8be6\u7ec6\u4fe1\u606f\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e09\u3001\u4f7f\u7528Python\u5185\u7f6e\u51fd\u6570\u67e5\u770b\u5e93<\/p>\n<\/p>\n<p><p>Python\u63d0\u4f9b\u4e86\u4e00\u4e9b\u5185\u7f6e\u51fd\u6570\uff0c\u53ef\u4ee5\u5728\u4e0d\u501f\u52a9\u5916\u90e8\u5de5\u5177\u7684\u60c5\u51b5\u4e0b\u67e5\u770b\u5e93\u7684\u8be6\u7ec6\u4fe1\u606f\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4f7f\u7528help()\u51fd\u6570<\/strong><\/p>\n<\/p>\n<p><p><code>help()<\/code>\u51fd\u6570\u53ef\u4ee5\u7528\u6765\u67e5\u770b\u67d0\u4e2a\u5e93\u7684\u6587\u6863\u4fe1\u606f\u3002\u901a\u8fc7\u5728Python\u89e3\u91ca\u5668\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff0c\u53ef\u4ee5\u83b7\u53d6\u5e93\u7684\u8be6\u7ec6\u6587\u6863\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy<\/p>\n<p>help(numpy)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u8f93\u51fa<code>numpy<\/code>\u5e93\u7684\u8be6\u7ec6\u6587\u6863\uff0c\u5305\u62ec\u6a21\u5757\u3001\u51fd\u6570\u548c\u7c7b\u7684\u4fe1\u606f\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528dir()\u51fd\u6570<\/strong><\/p>\n<\/p>\n<p><p><code>dir()<\/code>\u51fd\u6570\u53ef\u4ee5\u5217\u51fa\u4e00\u4e2a\u6a21\u5757\u4e2d\u5b9a\u4e49\u7684\u6240\u6709\u540d\u79f0\uff0c\u5305\u62ec\u53d8\u91cf\u3001\u51fd\u6570\u548c\u7c7b\u3002\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u53ef\u4ee5\u67e5\u770b\u67d0\u4e2a\u5e93\u4e2d\u7684\u6240\u6709\u6a21\u5757\u548c\u65b9\u6cd5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy<\/p>\n<p>dir(numpy)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u8f93\u51fa<code>numpy<\/code>\u5e93\u4e2d\u7684\u6240\u6709\u53ef\u7528\u6a21\u5757\u548c\u65b9\u6cd5\u540d\u79f0\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u56db\u3001\u4f7f\u7528Python IDE\u67e5\u770b\u5e93<\/p>\n<\/p>\n<p><p>\u8bb8\u591aPython\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u63d0\u4f9b\u4e86\u67e5\u770b\u5e93\u4fe1\u606f\u7684\u529f\u80fd\uff0c\u4f8b\u5982PyCharm\u3001VSCode\u7b49\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4f7f\u7528PyCharm<\/strong><\/p>\n<\/p>\n<p><p>\u5728PyCharm\u4e2d\uff0c\u53ef\u4ee5\u6253\u5f00\u201cProject Interpreter\u201d\u7a97\u53e3\uff0c\u67e5\u770b\u5f53\u524d\u9879\u76ee\u4e2d\u5b89\u88c5\u7684\u6240\u6709\u5e93\u53ca\u5176\u7248\u672c\u3002<\/p>\n<\/p>\n<ul>\n<li>\u6253\u5f00PyCharm\u3002<\/li>\n<li>\u5bfc\u822a\u5230File &gt; Settings &gt; Project: [Project Name] &gt; Python Interpreter\u3002<\/li>\n<li>\u5728\u6b64\u7a97\u53e3\u4e2d\uff0c\u53ef\u4ee5\u770b\u5230\u6240\u6709\u5df2\u5b89\u88c5\u5e93\u7684\u5217\u8868\u53ca\u5176\u7248\u672c\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528VSCode<\/strong><\/p>\n<\/p>\n<p><p>\u5728VSCode\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u201cPython: Select Interpreter\u201d\u547d\u4ee4\u67e5\u770b\u9879\u76ee\u4e2d\u4f7f\u7528\u7684Python\u73af\u5883\u53ca\u5176\u5df2\u5b89\u88c5\u5e93\u3002<\/p>\n<\/p>\n<ul>\n<li>\u6253\u5f00VSCode\u3002<\/li>\n<li>\u4f7f\u7528\u5feb\u6377\u952e <code>Ctrl + Shift + P<\/code> \u6253\u5f00\u547d\u4ee4\u9762\u677f\u3002<\/li>\n<li>\u8f93\u5165\u201cPython: Select Interpreter\u201d\u5e76\u9009\u62e9\u5408\u9002\u7684Python\u73af\u5883\u3002<\/li>\n<li>\u5728\u7ec8\u7aef\u4e2d\u4f7f\u7528<code>pip list<\/code>\u6216<code>conda list<\/code>\u547d\u4ee4\u67e5\u770b\u5df2\u5b89\u88c5\u5e93\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><p>\u4e94\u3001\u603b\u7ed3<\/p>\n<\/p>\n<p><p>\u67e5\u770bPython\u4e2d\u7684\u5e93\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u65b9\u5f0f\u5b9e\u73b0\uff0c\u65e0\u8bba\u662f\u4f7f\u7528\u547d\u4ee4\u884c\u5de5\u5177\u5982<code>pip<\/code>\u548c<code>conda<\/code>\uff0c\u8fd8\u662f\u4f7f\u7528Python\u5185\u7f6e\u51fd\u6570\u5982<code>help()<\/code>\u548c<code>dir()<\/code>\uff0c\u90fd\u80fd\u591f\u5e2e\u52a9\u6211\u4eec\u4e86\u89e3\u5e93\u7684\u8be6\u7ec6\u4fe1\u606f\u3002\u8fd9\u4e9b\u65b9\u6cd5\u4e0d\u4ec5\u53ef\u4ee5\u8ba9\u6211\u4eec\u638c\u63e1\u5e93\u7684\u7248\u672c\u548c\u4f9d\u8d56\u5173\u7cfb\uff0c\u8fd8\u53ef\u4ee5\u6df1\u5165\u4e86\u89e3\u5e93\u7684\u529f\u80fd\u548c\u7528\u6cd5\u3002\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\u53ef\u4ee5\u8ba9\u6211\u4eec\u5728\u5f00\u53d1\u8fc7\u7a0b\u4e2d\u66f4\u597d\u5730\u7ba1\u7406\u548c\u4f7f\u7528Python\u5e93\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u67e5\u770b\u5df2\u5b89\u88c5\u7684\u5e93\u5217\u8868\uff1f<\/strong><br \/>\u60a8\u53ef\u4ee5\u4f7f\u7528<code>pip list<\/code>\u547d\u4ee4\u5728\u7ec8\u7aef\u6216\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u67e5\u770b\u5f53\u524d\u73af\u5883\u4e0b\u5df2\u5b89\u88c5\u7684\u6240\u6709\u5e93\u53ca\u5176\u7248\u672c\u3002\u8fd9\u5c06\u5217\u51fa\u6240\u6709\u5e93\u7684\u540d\u79f0\u548c\u7248\u672c\u53f7\uff0c\u65b9\u4fbf\u60a8\u7ba1\u7406\u548c\u66f4\u65b0\u6240\u9700\u7684\u5e93\u3002<\/p>\n<p><strong>\u5982\u4f55\u67e5\u627e\u7279\u5b9a\u5e93\u7684\u8be6\u7ec6\u4fe1\u606f\uff1f<\/strong><br \/>\u8981\u83b7\u53d6\u7279\u5b9a\u5e93\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u4f8b\u5982\u7248\u672c\u53f7\u548c\u5b89\u88c5\u8def\u5f84\uff0c\u53ef\u4ee5\u4f7f\u7528<code>pip show \u5e93\u540d<\/code>\u547d\u4ee4\u3002\u6b64\u547d\u4ee4\u5c06\u663e\u793a\u5e93\u7684\u5143\u6570\u636e\uff0c\u5305\u62ec\u4f5c\u8005\u3001\u8bb8\u53ef\u8bc1\u3001\u4f9d\u8d56\u5173\u7cfb\u7b49\uff0c\u5e2e\u52a9\u60a8\u66f4\u597d\u5730\u4e86\u89e3\u5e93\u7684\u7279\u6027\u3002<\/p>\n<p><strong>\u5982\u4f55\u67e5\u770bPython\u5e93\u7684\u6587\u6863\u548c\u4f7f\u7528\u793a\u4f8b\uff1f<\/strong><br \/>\u5927\u591a\u6570Python\u5e93\u5728\u5176GitHub\u9875\u9762\u6216\u5b98\u65b9\u7f51\u7ad9\u4e0a\u90fd\u6709\u8be6\u7ec6\u7684\u6587\u6863\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7\u8bbf\u95ee\u8fd9\u4e9b\u8d44\u6e90\uff0c\u67e5\u627e\u5b89\u88c5\u8bf4\u660e\u3001API\u6587\u6863\u548c\u4f7f\u7528\u793a\u4f8b\u7b49\u4fe1\u606f\u3002\u8fd9\u6837\uff0c\u60a8\u53ef\u4ee5\u4e86\u89e3\u5982\u4f55\u6b63\u786e\u4f7f\u7528\u8be5\u5e93\u5e76\u53d1\u6325\u5176\u529f\u80fd\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python\u4e2d\u67e5\u770b\u67d0\u4e2a\u5e93\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u65b9\u5f0f\u5b9e\u73b0\uff0c\u5305\u62ec\u4f7f\u7528pip\u3001conda\u547d\u4ee4\u67e5\u770b\u5df2\u5b89\u88c5\u7684\u5e93\u53ca\u5176\u7248\u672c\uff0c\u4f7f\u7528he [&hellip;]","protected":false},"author":3,"featured_media":970172,"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\/970166"}],"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=970166"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/970166\/revisions"}],"predecessor-version":[{"id":970174,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/970166\/revisions\/970174"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/970172"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=970166"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=970166"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=970166"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}