{"id":980206,"date":"2024-12-27T06:52:42","date_gmt":"2024-12-26T22:52:42","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/980206.html"},"modified":"2024-12-27T06:52:45","modified_gmt":"2024-12-26T22:52:45","slug":"python%e5%a6%82%e4%bd%95%e6%89%93%e5%bc%80%e8%87%aa%e5%b8%a6%e5%87%bd%e6%95%b0","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/980206.html","title":{"rendered":"python\u5982\u4f55\u6253\u5f00\u81ea\u5e26\u51fd\u6570"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24205713\/503c4481-bd4d-474e-9e3d-8944d9e49b7e.webp\" alt=\"python\u5982\u4f55\u6253\u5f00\u81ea\u5e26\u51fd\u6570\" \/><\/p>\n<p><p> <strong>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u65b9\u5f0f\u67e5\u770b\u548c\u4f7f\u7528\u81ea\u5e26\u51fd\u6570\uff0c\u5982\u4f7f\u7528Python\u7684\u5185\u7f6e<code>help()<\/code>\u51fd\u6570\u3001\u5728\u7ebf\u6587\u6863\u3001\u4ee5\u53ca\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u7684\u81ea\u52a8\u8865\u5168\u529f\u80fd\u3002<\/strong>\u5728\u8fd9\u4e4b\u4e2d\uff0c\u4f7f\u7528<code>help()<\/code>\u51fd\u6570\u662f\u6700\u76f4\u63a5\u7684\u65b9\u6cd5\u3002\u4f60\u53ea\u9700\u8981\u5728Python\u89e3\u91ca\u5668\u4e2d\u8f93\u5165<code>help()<\/code>\uff0c\u7136\u540e\u8f93\u5165\u4f60\u60f3\u4e86\u89e3\u7684\u51fd\u6570\u540d\u79f0\uff0c\u5373\u53ef\u83b7\u5f97\u8be5\u51fd\u6570\u7684\u8be6\u7ec6\u8bf4\u660e\u548c\u4f7f\u7528\u793a\u4f8b\u3002\u8fd9\u79cd\u65b9\u5f0f\u5bf9\u4e8e\u5feb\u901f\u67e5\u9605\u51fd\u6570\u7528\u9014\u975e\u5e38\u6709\u5e2e\u52a9\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u4f7f\u7528<code>help()<\/code>\u51fd\u6570<\/p>\n<\/p>\n<p><p>\u5728Python\u4e2d\uff0c<code>help()<\/code>\u51fd\u6570\u662f\u4e00\u4e2a\u975e\u5e38\u6709\u7528\u7684\u5de5\u5177\u3002\u5b83\u5141\u8bb8\u4f60\u5728\u4e0d\u79bb\u5f00Python\u89e3\u91ca\u5668\u7684\u60c5\u51b5\u4e0b\u67e5\u770b\u4efb\u4f55\u5185\u7f6e\u51fd\u6570\u3001\u6a21\u5757\u6216\u5bf9\u8c61\u7684\u6587\u6863\u5b57\u7b26\u4e32\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5982\u4f55\u4f7f\u7528<code>help()<\/code>\u51fd\u6570<\/strong><\/p>\n<\/p>\n<p><p>\u5f53\u4f60\u60f3\u8981\u67e5\u770b\u67d0\u4e2a\u51fd\u6570\u7684\u7528\u6cd5\u65f6\uff0c\u53ea\u9700\u5728Python\u89e3\u91ca\u5668\u4e2d\u8c03\u7528<code>help()<\/code>\uff0c\u5e76\u5c06\u51fd\u6570\u540d\u79f0\u4f5c\u4e3a\u53c2\u6570\u3002\u4f8b\u5982\uff0c\u8981\u67e5\u770b<code>len()<\/code>\u51fd\u6570\u7684\u6587\u6863\uff0c\u4f60\u53ef\u4ee5\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">help(len)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u8fd4\u56de<code>len()<\/code>\u51fd\u6570\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u5305\u62ec\u5b83\u7684\u529f\u80fd\u3001\u53c2\u6570\u4ee5\u53ca\u8fd4\u56de\u503c\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528<code>help()<\/code>\u67e5\u770b\u6a21\u5757<\/strong><\/p>\n<\/p>\n<p><p>\u9664\u4e86\u51fd\u6570\uff0c\u4f60\u4e5f\u53ef\u4ee5\u7528<code>help()<\/code>\u67e5\u770b\u6a21\u5757\u7684\u6587\u6863\u3002\u4f8b\u5982\uff0c\u5982\u679c\u4f60\u60f3\u4e86\u89e3<code>math<\/code>\u6a21\u5757\u7684\u6240\u6709\u51fd\u6570\u548c\u5e38\u91cf\uff0c\u4f60\u53ef\u4ee5\u8f93\u5165\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import math<\/p>\n<p>help(math)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u663e\u793a\u8be5\u6a21\u5757\u4e2d\u7684\u6240\u6709\u53ef\u7528\u51fd\u6570\u53ca\u5176\u7b80\u8981\u8bf4\u660e\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e8c\u3001\u67e5\u770bPython\u5728\u7ebf\u6587\u6863<\/p>\n<\/p>\n<p><p>Python\u6709\u4e00\u4e2a\u975e\u5e38\u5168\u9762\u7684\u5728\u7ebf\u6587\u6863\uff0c\u6db5\u76d6\u4e86\u6240\u6709\u5185\u7f6e\u51fd\u6570\u548c\u6a21\u5757\u3002\u901a\u8fc7\u8bbf\u95ee<a href=\"https:\/\/docs.python.org\/3\/\">Python\u5b98\u65b9\u6587\u6863<\/a>\uff0c\u4f60\u53ef\u4ee5\u641c\u7d22\u4efb\u4f55\u51fd\u6570\u6216\u6a21\u5757\uff0c\u5e76\u67e5\u770b\u5176\u8be6\u7ec6\u7684\u8bf4\u660e\u548c\u793a\u4f8b\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u6587\u6863\u7ed3\u6784<\/strong><\/p>\n<\/p>\n<p><p>Python\u7684\u5728\u7ebf\u6587\u6863\u5305\u62ec\u8bed\u8a00\u53c2\u8003\u3001\u5e93\u53c2\u8003\u3001\u6559\u7a0b\u548c\u793a\u4f8b\u7b49\u90e8\u5206\u3002\u5e93\u53c2\u8003\u90e8\u5206\u8be6\u7ec6\u5217\u51fa\u4e86\u6240\u6709\u5185\u7f6e\u51fd\u6570\u548c\u6a21\u5757\u7684\u7528\u6cd5\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u641c\u7d22\u529f\u80fd<\/strong><\/p>\n<\/p>\n<p><p>\u5728\u6587\u6863\u9875\u9762\u4e0a\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u641c\u7d22\u6846\u5feb\u901f\u627e\u5230\u4f60\u9700\u8981\u7684\u4fe1\u606f\u3002\u8f93\u5165\u51fd\u6570\u6216\u6a21\u5757\u540d\u79f0\uff0c\u5373\u53ef\u8df3\u8f6c\u5230\u76f8\u5173\u7684\u6587\u6863\u90e8\u5206\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e09\u3001\u4f7f\u7528IDE\u7684\u81ea\u52a8\u8865\u5168\u529f\u80fd<\/p>\n<\/p>\n<p><p>\u73b0\u4ee3Python\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\uff0c\u5982PyCharm\u3001VSCode\u7b49\uff0c\u90fd\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u81ea\u52a8\u8865\u5168\u548c\u6587\u6863\u67e5\u770b\u529f\u80fd\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u81ea\u52a8\u8865\u5168<\/strong><\/p>\n<\/p>\n<p><p>\u5f53\u4f60\u5728IDE\u4e2d\u8f93\u5165\u51fd\u6570\u540d\u79f0\u65f6\uff0cIDE\u901a\u5e38\u4f1a\u81ea\u52a8\u663e\u793a\u8be5\u51fd\u6570\u7684\u53c2\u6570\u548c\u7b80\u8981\u8bf4\u660e\u3002\u8fd9\u80fd\u5e2e\u52a9\u4f60\u5feb\u901f\u7406\u89e3\u51fd\u6570\u7684\u7528\u6cd5\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5185\u7f6e\u6587\u6863\u67e5\u770b<\/strong><\/p>\n<\/p>\n<p><p>\u5927\u591a\u6570IDE\u5141\u8bb8\u4f60\u5728\u51fd\u6570\u540d\u79f0\u4e0a\u53f3\u952e\u70b9\u51fb\uff0c\u5e76\u9009\u62e9\u201c\u67e5\u770b\u6587\u6863\u201d\u6216\u7c7b\u4f3c\u9009\u9879\uff0c\u4ee5\u83b7\u53d6\u8be6\u7ec6\u7684\u6587\u6863\u4fe1\u606f\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u56db\u3001\u63a2\u7d22Python\u6e90\u7801<\/p>\n<\/p>\n<p><p>Python\u662f\u5f00\u6e90\u7684\uff0c\u8fd9\u610f\u5473\u7740\u4f60\u53ef\u4ee5\u67e5\u770b\u5176\u6e90\u7801\u4ee5\u4e86\u89e3\u81ea\u5e26\u51fd\u6570\u7684\u5b9e\u73b0\u7ec6\u8282\u3002\u8fd9\u5bf9\u4e8e\u6df1\u5165\u7406\u89e3Python\u7684\u5de5\u4f5c\u539f\u7406\u975e\u5e38\u6709\u5e2e\u52a9\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u67e5\u770b\u6807\u51c6\u5e93\u6e90\u7801<\/strong><\/p>\n<\/p>\n<p><p>Python\u7684\u6807\u51c6\u5e93\u6e90\u7801\u53ef\u4ee5\u5728\u4f60\u672c\u5730\u7684Python\u5b89\u88c5\u76ee\u5f55\u4e2d\u627e\u5230\u3002\u901a\u8fc7\u9605\u8bfb\u6e90\u7801\uff0c\u4f60\u53ef\u4ee5\u4e86\u89e3\u6bcf\u4e2a\u51fd\u6570\u7684\u5e95\u5c42\u5b9e\u73b0\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528GitHub<\/strong><\/p>\n<\/p>\n<p><p>Python\u7684\u6e90\u7801\u4e5f\u6258\u7ba1\u5728GitHub\u4e0a\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7\u8bbf\u95ee<a href=\"https:\/\/github.com\/python\/cpython\">Python\u7684GitHub\u4ed3\u5e93<\/a>\u6765\u6d4f\u89c8\u6700\u65b0\u7684\u6e90\u7801\u7248\u672c\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e94\u3001\u4f7f\u7528<code>dir()<\/code>\u51fd\u6570\u63a2\u7d22\u5bf9\u8c61<\/p>\n<\/p>\n<p><p>\u5728Python\u4e2d\uff0c<code>dir()<\/code>\u51fd\u6570\u53ef\u4ee5\u7528\u6765\u5217\u51fa\u5bf9\u8c61\u7684\u6240\u6709\u5c5e\u6027\u548c\u65b9\u6cd5\u3002\u901a\u8fc7\u7ed3\u5408<code>dir()<\/code>\u548c<code>help()<\/code>\uff0c\u4f60\u53ef\u4ee5\u5feb\u901f\u63a2\u7d22\u5bf9\u8c61\u7684\u529f\u80fd\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4f7f\u7528<code>dir()<\/code><\/strong><\/p>\n<\/p>\n<p><p>\u4f8b\u5982\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528<code>dir()<\/code>\u6765\u67e5\u770b\u5b57\u7b26\u4e32\u5bf9\u8c61\u7684\u6240\u6709\u65b9\u6cd5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">dir(str)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u8fd4\u56de\u4e00\u4e2a\u5217\u8868\uff0c\u5305\u542b\u6240\u6709\u5b57\u7b26\u4e32\u65b9\u6cd5\u7684\u540d\u79f0\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u7ed3\u5408<code>help()<\/code><\/strong><\/p>\n<\/p>\n<p><p>\u4e00\u65e6\u4f60\u627e\u5230\u611f\u5174\u8da3\u7684\u65b9\u6cd5\uff0c\u53ef\u4ee5\u4f7f\u7528<code>help()<\/code>\u67e5\u770b\u5176\u8be6\u7ec6\u4fe1\u606f\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">help(str.upper)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u663e\u793a<code>str.upper()<\/code>\u65b9\u6cd5\u7684\u6587\u6863\u5b57\u7b26\u4e32\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u516d\u3001\u603b\u7ed3<\/p>\n<\/p>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u65b9\u6cd5\uff0c\u4f60\u53ef\u4ee5\u5feb\u901f\u800c\u5168\u9762\u5730\u4e86\u89e3Python\u81ea\u5e26\u51fd\u6570\u7684\u7528\u6cd5\u548c\u5b9e\u73b0\u7ec6\u8282\u3002\u8fd9\u4e0d\u4ec5\u80fd\u5e2e\u52a9\u4f60\u66f4\u9ad8\u6548\u5730\u7f16\u5199Python\u4ee3\u7801\uff0c\u8fd8\u80fd\u52a0\u6df1\u4f60\u5bf9Python\u8bed\u8a00\u7684\u7406\u89e3\u3002\u5728\u65e5\u5e38\u5f00\u53d1\u4e2d\uff0c\u5145\u5206\u5229\u7528\u8fd9\u4e9b\u5de5\u5177\u548c\u8d44\u6e90\uff0c\u53ef\u4ee5\u6781\u5927\u63d0\u9ad8\u4f60\u7684\u7f16\u7a0b\u6548\u7387\u548c\u89e3\u51b3\u95ee\u9898\u7684\u80fd\u529b\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u67e5\u770b\u81ea\u5e26\u51fd\u6570\u7684\u5217\u8868\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u5185\u7f6e\u7684<code>dir()<\/code>\u51fd\u6570\u6765\u67e5\u770b\u5bf9\u8c61\u7684\u5c5e\u6027\u548c\u65b9\u6cd5\u3002\u5bf9\u4e8e\u5185\u7f6e\u51fd\u6570\uff0c\u4f60\u53ef\u4ee5\u7b80\u5355\u5730\u5728Python\u89e3\u91ca\u5668\u4e2d\u8f93\u5165<code>dir(__builtins__)<\/code>\uff0c\u8fd9\u5c06\u8fd4\u56de\u4e00\u4e2a\u5305\u542b\u6240\u6709\u5185\u7f6e\u51fd\u6570\u548c\u5f02\u5e38\u7684\u5217\u8868\u3002\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\uff0c\u4f60\u53ef\u4ee5\u5feb\u901f\u627e\u5230\u53ef\u7528\u7684\u81ea\u5e26\u51fd\u6570\u3002<\/p>\n<p><strong>\u5982\u4f55\u83b7\u53d6Python\u81ea\u5e26\u51fd\u6570\u7684\u8be6\u7ec6\u4fe1\u606f\uff1f<\/strong><br \/>\u8981\u83b7\u53d6\u67d0\u4e2a\u81ea\u5e26\u51fd\u6570\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u53ef\u4ee5\u4f7f\u7528<code>help()<\/code>\u51fd\u6570\u3002\u4f8b\u5982\uff0c\u8f93\u5165<code>help(len)<\/code>\u53ef\u4ee5\u67e5\u770b<code>len()<\/code>\u51fd\u6570\u7684\u4f7f\u7528\u65b9\u6cd5\u3001\u53c2\u6570\u548c\u8fd4\u56de\u503c\u7b49\u4fe1\u606f\u3002\u8fd9\u662f\u4e00\u4e2a\u5f88\u597d\u7684\u65b9\u5f0f\u6765\u6df1\u5165\u4e86\u89e3\u5404\u4e2a\u81ea\u5e26\u51fd\u6570\u7684\u529f\u80fd\u548c\u7528\u6cd5\u3002<\/p>\n<p><strong>\u5982\u4f55\u67e5\u770b\u67d0\u4e2a\u81ea\u5e26\u51fd\u6570\u7684\u6e90\u4ee3\u7801\uff1f<\/strong><br \/>\u5bf9\u4e8ePython\u7684\u5185\u7f6e\u51fd\u6570\uff0c\u6e90\u4ee3\u7801\u901a\u5e38\u4e0d\u662f\u76f4\u63a5\u53ef\u89c1\u7684\uff0c\u56e0\u4e3a\u5b83\u4eec\u662f\u7528C\u8bed\u8a00\u5b9e\u73b0\u7684\u3002\u4e0d\u8fc7\uff0c\u4f60\u53ef\u4ee5\u67e5\u770bPython\u7684\u5b98\u65b9\u6587\u6863\uff0c\u91cc\u9762\u8be6\u7ec6\u5217\u51fa\u4e86\u8fd9\u4e9b\u51fd\u6570\u7684\u884c\u4e3a\u548c\u7528\u6cd5\u3002\u5982\u679c\u4f60\u6709\u5174\u8da3\u4e86\u89e3\u5176\u5b9e\u73b0\uff0c\u53ef\u4ee5\u8bbf\u95eePython\u7684GitHub\u4ed3\u5e93\uff0c\u67e5\u627e\u5bf9\u5e94\u7248\u672c\u7684\u6e90\u4ee3\u7801\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u65b9\u5f0f\u67e5\u770b\u548c\u4f7f\u7528\u81ea\u5e26\u51fd\u6570\uff0c\u5982\u4f7f\u7528Python\u7684\u5185\u7f6ehelp()\u51fd\u6570\u3001\u5728\u7ebf\u6587\u6863\u3001\u4ee5\u53ca [&hellip;]","protected":false},"author":3,"featured_media":980216,"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\/980206"}],"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=980206"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/980206\/revisions"}],"predecessor-version":[{"id":980221,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/980206\/revisions\/980221"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/980216"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=980206"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=980206"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=980206"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}