{"id":959404,"date":"2024-12-27T03:40:20","date_gmt":"2024-12-26T19:40:20","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/959404.html"},"modified":"2024-12-27T03:40:22","modified_gmt":"2024-12-26T19:40:22","slug":"%e5%a6%82%e4%bd%95%e6%9f%a5%e8%af%a2python%e4%b8%8b%e6%a8%a1%e5%9d%97","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/959404.html","title":{"rendered":"\u5982\u4f55\u67e5\u8be2python\u4e0b\u6a21\u5757"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25102233\/38198fae-5995-4772-874c-fafcb7b62cae.webp\" alt=\"\u5982\u4f55\u67e5\u8be2python\u4e0b\u6a21\u5757\" \/><\/p>\n<p><p> <strong>\u5728Python\u4e2d\u67e5\u8be2\u6a21\u5757\u7684\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u5305\u62ec\u4f7f\u7528<code>pip list<\/code>\u547d\u4ee4\u3001<code>pip show<\/code>\u547d\u4ee4\u3001<code>help()<\/code>\u51fd\u6570\u3001<code>dir()<\/code>\u51fd\u6570\u3001<code>__doc__<\/code>\u5c5e\u6027\u3001\u5728\u7ebf\u6587\u6863\u7b49\u3002\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u8fd9\u4e9b\u65b9\u6cd5\uff0c\u5e2e\u52a9\u4f60\u66f4\u597d\u5730\u4e86\u89e3\u548c\u7ba1\u7406Python\u6a21\u5757\u3002<\/strong><\/p>\n<\/p>\n<p><p>\u4e00\u3001\u4f7f\u7528<code>pip list<\/code>\u547d\u4ee4<br \/>Python\u4e2d\u7684<code>pip<\/code>\u5de5\u5177\u662f\u7528\u4e8e\u7ba1\u7406Python\u5305\u7684\u6807\u51c6\u5de5\u5177\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528<code>pip list<\/code>\u547d\u4ee4\u6765\u67e5\u770b\u5f53\u524dPython\u73af\u5883\u4e2d\u5df2\u5b89\u88c5\u7684\u6240\u6709\u6a21\u5757\u3002\u8fd9\u5bf9\u4e8e\u68c0\u67e5\u67d0\u4e2a\u6a21\u5757\u662f\u5426\u5df2\u5b89\u88c5\u6216\u4e86\u89e3\u5f53\u524d\u73af\u5883\u4e0b\u6709\u54ea\u4e9b\u6a21\u5757\u975e\u5e38\u6709\u7528\u3002\u6267\u884c\u547d\u4ee4\u65f6\uff0c<code>pip<\/code>\u4f1a\u5217\u51fa\u6240\u6709\u6a21\u5757\u53ca\u5176\u7248\u672c\u53f7\u3002\u8fd9\u4e2a\u547d\u4ee4\u7b80\u5355\u76f4\u63a5\uff0c\u662f\u5feb\u901f\u83b7\u53d6\u6a21\u5757\u4fe1\u606f\u7684\u6709\u6548\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><p>\u4e8c\u3001\u4f7f\u7528<code>pip show<\/code>\u547d\u4ee4<br \/>\u5982\u679c\u4f60\u60f3\u4e86\u89e3\u67d0\u4e2a\u7279\u5b9a\u6a21\u5757\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u53ef\u4ee5\u4f7f\u7528<code>pip show<\/code>\u547d\u4ee4\u3002\u6b64\u547d\u4ee4\u4f1a\u63d0\u4f9b\u6a21\u5757\u7684\u540d\u79f0\u3001\u7248\u672c\u3001\u6458\u8981\u3001\u6240\u9700\u4f9d\u8d56\u3001\u5b89\u88c5\u8def\u5f84\u7b49\u4fe1\u606f\u3002\u901a\u8fc7\u8fd9\u4e9b\u4fe1\u606f\uff0c\u4f60\u53ef\u4ee5\u66f4\u597d\u5730\u4e86\u89e3\u6a21\u5757\u7684\u7528\u9014\u3001\u7248\u672c\u517c\u5bb9\u6027\u4ee5\u53ca\u6a21\u5757\u6587\u4ef6\u7684\u4f4d\u7f6e\uff0c\u8fd9\u5728\u8c03\u8bd5\u6216\u6df1\u5165\u5b66\u4e60\u6a21\u5757\u65f6\u975e\u5e38\u6709\u5e2e\u52a9\u3002<\/p>\n<\/p>\n<p><p>\u4e09\u3001\u4f7f\u7528<code>help()<\/code>\u51fd\u6570<br \/>Python\u63d0\u4f9b\u4e86\u5185\u7f6e\u7684<code>help()<\/code>\u51fd\u6570\uff0c\u53ef\u4ee5\u7528\u6765\u83b7\u53d6\u6a21\u5757\u3001\u7c7b\u3001\u51fd\u6570\u6216\u65b9\u6cd5\u7684\u5e2e\u52a9\u4fe1\u606f\u3002\u901a\u8fc7\u8f93\u5165<code>help(module_name)<\/code>\uff0c\u4f60\u53ef\u4ee5\u67e5\u770b\u6a21\u5757\u7684\u8be6\u7ec6\u6587\u6863\uff0c\u5305\u62ec\u6a21\u5757\u7684\u529f\u80fd\u3001\u53ef\u7528\u7684\u7c7b\u548c\u65b9\u6cd5\u3002\u8fd9\u662f\u6df1\u5165\u5b66\u4e60\u6a21\u5757\u529f\u80fd\u548c\u7528\u6cd5\u7684\u4e00\u4e2a\u6709\u6548\u9014\u5f84\uff0c\u5c24\u5176\u5bf9\u4e8e\u90a3\u4e9b\u6ca1\u6709\u9644\u5e26\u8be6\u7ec6\u6587\u6863\u7684\u7b2c\u4e09\u65b9\u6a21\u5757\u3002<\/p>\n<\/p>\n<p><p>\u56db\u3001\u4f7f\u7528<code>dir()<\/code>\u51fd\u6570<br \/><code>dir()<\/code>\u51fd\u6570\u53ef\u4ee5\u5217\u51fa\u6a21\u5757\u7684\u6240\u6709\u5c5e\u6027\u548c\u65b9\u6cd5\u3002\u901a\u8fc7\u8c03\u7528<code>dir(module_name)<\/code>\uff0c\u4f60\u53ef\u4ee5\u770b\u5230\u6a21\u5757\u4e2d\u5b9a\u4e49\u7684\u6240\u6709\u540d\u79f0\uff0c\u5305\u62ec\u51fd\u6570\u3001\u7c7b\u548c\u53d8\u91cf\u7b49\u3002\u8fd9\u6709\u52a9\u4e8e\u5feb\u901f\u4e86\u89e3\u6a21\u5757\u7684\u7ed3\u6784\u548c\u53ef\u7528\u7684\u529f\u80fd\uff0c\u7279\u522b\u662f\u5728\u4f7f\u7528\u5927\u578b\u6a21\u5757\u65f6\u3002<\/p>\n<\/p>\n<p><p>\u4e94\u3001\u67e5\u770b<code>__doc__<\/code>\u5c5e\u6027<br \/>\u6bcf\u4e2aPython\u6a21\u5757\u3001\u7c7b\u6216\u51fd\u6570\u90fd\u6709\u4e00\u4e2a<code>__doc__<\/code>\u5c5e\u6027\uff0c\u5176\u4e2d\u5305\u542b\u8be5\u5bf9\u8c61\u7684\u6587\u6863\u5b57\u7b26\u4e32\u3002\u901a\u8fc7\u8bbf\u95ee<code>module_name.__doc__<\/code>\uff0c\u4f60\u53ef\u4ee5\u67e5\u770b\u6a21\u5757\u7684\u7b80\u8981\u8bf4\u660e\u548c\u4f7f\u7528\u6307\u5357\u3002\u5c3d\u7ba1\u8fd9\u901a\u5e38\u4e0d\u4f1a\u63d0\u4f9b\u5168\u9762\u7684\u4fe1\u606f\uff0c\u4f46\u5b83\u662f\u5feb\u901f\u67e5\u770b\u6a21\u5757\u57fa\u672c\u529f\u80fd\u548c\u7528\u6cd5\u7684\u4e00\u4e2a\u597d\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><p>\u516d\u3001\u5728\u7ebf\u6587\u6863\u548c\u793e\u533a\u8d44\u6e90<br \/>\u9664\u4e86\u4e0a\u8ff0\u65b9\u6cd5\uff0c\u8bb8\u591aPython\u6a21\u5757\u90fd\u6709\u5728\u7ebf\u6587\u6863\u548c\u793e\u533a\u652f\u6301\u3002\u5b98\u65b9\u6587\u6863\u901a\u5e38\u662f\u6700\u53ef\u9760\u7684\u4fe1\u606f\u6765\u6e90\uff0c\u6db5\u76d6\u6a21\u5757\u7684\u5b89\u88c5\u3001\u529f\u80fd\u3001\u7528\u6cd5\u793a\u4f8b\u7b49\u3002\u793e\u533a\u8d44\u6e90\u5982\u8bba\u575b\u3001\u535a\u5ba2\u548c\u95ee\u7b54\u7f51\u7ad9\u4e5f\u63d0\u4f9b\u4e86\u5927\u91cf\u7684\u5b9e\u7528\u4fe1\u606f\u548c\u4f7f\u7528\u7ecf\u9a8c\uff0c\u5e2e\u52a9\u4f60\u66f4\u597d\u5730\u638c\u63e1\u6a21\u5757\u7684\u4f7f\u7528\u3002<\/p>\n<\/p>\n<p><p><strong>\u603b\u7ed3<\/strong><br \/>\u901a\u8fc7\u4f7f\u7528<code>pip list<\/code>\u3001<code>pip show<\/code>\u3001<code>help()<\/code>\u3001<code>dir()<\/code>\u3001<code>__doc__<\/code>\u53ca\u5728\u7ebf\u6587\u6863\u7b49\u591a\u79cd\u65b9\u6cd5\uff0c\u4f60\u53ef\u4ee5\u5168\u9762\u4e86\u89e3Python\u6a21\u5757\u7684\u5b89\u88c5\u60c5\u51b5\u3001\u529f\u80fd\u548c\u7528\u6cd5\u3002\u8fd9\u4e0d\u4ec5\u6709\u52a9\u4e8e\u6a21\u5757\u7ba1\u7406\uff0c\u4e5f\u4e3a\u6df1\u5165\u5b66\u4e60\u548c\u5e94\u7528Python\u6a21\u5757\u63d0\u4f9b\u4e86\u575a\u5b9e\u7684\u57fa\u7840\u3002\u65e0\u8bba\u662f\u5728\u5f00\u53d1\u65b0\u9879\u76ee\u8fd8\u662f\u7ef4\u62a4\u73b0\u6709\u4ee3\u7801\u65f6\uff0c\u8fd9\u4e9b\u5de5\u5177\u548c\u65b9\u6cd5\u90fd\u5c06\u662f\u4f60\u4e0d\u53ef\u6216\u7f3a\u7684\u52a9\u624b\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u67e5\u627e\u5df2\u5b89\u88c5\u7684\u6a21\u5757\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4\u884c\u5de5\u5177\u6765\u67e5\u8be2\u5df2\u5b89\u88c5\u7684\u6a21\u5757\u3002\u901a\u8fc7\u6253\u5f00\u7ec8\u7aef\u5e76\u8f93\u5165<code>pip list<\/code>\u6216<code>pip freeze<\/code>\u547d\u4ee4\uff0c\u60a8\u5c06\u83b7\u5f97\u4e00\u4e2a\u5df2\u5b89\u88c5\u6a21\u5757\u7684\u5217\u8868\uff0c\u5305\u542b\u6bcf\u4e2a\u6a21\u5757\u7684\u540d\u79f0\u548c\u7248\u672c\u53f7\u3002\u6b64\u5916\uff0c\u5728Python\u89e3\u91ca\u5668\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528<code>help(&#39;modules&#39;)<\/code>\u547d\u4ee4\u5217\u51fa\u6240\u6709\u53ef\u7528\u6a21\u5757\u3002<\/p>\n<p><strong>\u5728Python\u4e2d\u5982\u4f55\u68c0\u67e5\u6a21\u5757\u7684\u8be6\u7ec6\u4fe1\u606f\uff1f<\/strong><br \/>\u8981\u83b7\u53d6\u67d0\u4e2a\u7279\u5b9a\u6a21\u5757\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528Python\u7684<code>help()<\/code>\u51fd\u6570\u3002\u53ea\u9700\u5728Python\u89e3\u91ca\u5668\u4e2d\u8f93\u5165<code>import module_name<\/code>\u540e\u8ddf<code>help(module_name)<\/code>\uff0c\u66ff\u6362<code>module_name<\/code>\u4e3a\u60a8\u60f3\u8981\u67e5\u8be2\u7684\u6a21\u5757\u540d\uff0c\u5c31\u53ef\u4ee5\u67e5\u770b\u8be5\u6a21\u5757\u7684\u6587\u6863\u3001\u51fd\u6570\u548c\u7c7b\u7684\u8be6\u7ec6\u4fe1\u606f\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728Python\u4e2d\u641c\u7d22\u53ef\u7528\u6a21\u5757\u7684\u6587\u6863\u6216\u6559\u7a0b\uff1f<\/strong><br \/>\u8981\u67e5\u627e\u7279\u5b9a\u6a21\u5757\u7684\u6587\u6863\u6216\u6559\u7a0b\uff0c\u60a8\u53ef\u4ee5\u8bbf\u95ee\u5b98\u65b9Python\u6587\u6863\u7f51\u7ad9\uff08\u5982docs.python.org\uff09\u6216\u6a21\u5757\u7684GitHub\u9875\u9762\u3002\u8bb8\u591a\u6a21\u5757\u4e5f\u5728PyPI\uff08Python Package Index\uff09\u4e0a\u6709\u8be6\u7ec6\u7684\u4ecb\u7ecd\u548c\u4f7f\u7528\u793a\u4f8b\u3002\u901a\u8fc7\u641c\u7d22\u5f15\u64ce\u8f93\u5165\u6a21\u5757\u540d\u79f0\u52a0\u4e0a\u201cdocumentation\u201d\u6216\u201ctutorial\u201d\uff0c\u53ef\u4ee5\u627e\u5230\u4e30\u5bcc\u7684\u5b66\u4e60\u8d44\u6e90\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python\u4e2d\u67e5\u8be2\u6a21\u5757\u7684\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u5305\u62ec\u4f7f\u7528pip list\u547d\u4ee4\u3001pip show\u547d\u4ee4\u3001help()\u51fd\u6570\u3001d [&hellip;]","protected":false},"author":3,"featured_media":959411,"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\/959404"}],"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=959404"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/959404\/revisions"}],"predecessor-version":[{"id":959413,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/959404\/revisions\/959413"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/959411"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=959404"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=959404"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=959404"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}