{"id":1013883,"date":"2024-12-27T11:51:39","date_gmt":"2024-12-27T03:51:39","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1013883.html"},"modified":"2024-12-27T11:51:41","modified_gmt":"2024-12-27T03:51:41","slug":"python%e5%a6%82%e4%bd%95%e6%9f%a5%e7%9c%8b%e6%a8%a1%e5%9d%97%e5%8a%9f%e8%83%bd","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1013883.html","title":{"rendered":"python\u5982\u4f55\u67e5\u770b\u6a21\u5757\u529f\u80fd"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25094152\/e8c72452-e121-4e37-a49e-75ab2933e8b8.webp\" alt=\"python\u5982\u4f55\u67e5\u770b\u6a21\u5757\u529f\u80fd\" \/><\/p>\n<p><h3>PYTHON\u5982\u4f55\u67e5\u770b\u6a21\u5757\u529f\u80fd<\/h3>\n<\/p>\n<p><p>\u5728Python\u4e2d\uff0c\u67e5\u770b\u6a21\u5757\u529f\u80fd\u7684\u65b9\u6cd5\u6709\u5f88\u591a\uff0c\u5305\u62ec<strong>\u4f7f\u7528\u5185\u7f6e\u51fd\u6570\u3001\u67e5\u770b\u6a21\u5757\u7684\u5b98\u65b9\u6587\u6863\u3001\u4f7f\u7528IDE\u7684\u81ea\u52a8\u63d0\u793a\u529f\u80fd<\/strong>\u7b49\u3002\u5176\u4e2d\uff0c\u4f7f\u7528\u5185\u7f6e\u51fd\u6570\u662f\u6700\u76f4\u63a5\u7684\u65b9\u6cd5\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528<code>help()<\/code>\u51fd\u6570\u6765\u83b7\u53d6\u6a21\u5757\u7684\u6587\u6863\u5b57\u7b26\u4e32\uff0c\u4e86\u89e3\u6a21\u5757\u7684\u529f\u80fd\u548c\u7528\u6cd5\u3002\u4ee5<code>math<\/code>\u6a21\u5757\u4e3a\u4f8b\uff0c<code>help(math)<\/code>\u4f1a\u5217\u51fa\u8be5\u6a21\u5757\u4e2d\u7684\u6240\u6709\u51fd\u6570\u548c\u5e38\u91cf\uff0c\u5e76\u63d0\u4f9b\u7b80\u8981\u8bf4\u660e\u3002<\/p>\n<\/p>\n<p><p>\u4e0b\u9762\u8be6\u7ec6\u4ecb\u7ecd\u4e00\u4e9b\u65b9\u6cd5\uff0c\u5e2e\u52a9\u4f60\u66f4\u597d\u5730\u4e86\u89e3Python\u6a21\u5757\u7684\u529f\u80fd\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u4f7f\u7528\u5185\u7f6e\u51fd\u6570<\/h3>\n<\/p>\n<p><p>Python\u63d0\u4f9b\u4e86\u4e00\u4e9b\u5185\u7f6e\u51fd\u6570\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u67e5\u770b\u6a21\u5757\u7684\u529f\u80fd\u548c\u6587\u6863\u3002<\/p>\n<\/p>\n<p><h4>1.1 \u4f7f\u7528 <code>help()<\/code> \u51fd\u6570<\/h4>\n<\/p>\n<p><p><code>help()<\/code> \u662f\u4e00\u4e2a\u975e\u5e38\u6709\u7528\u7684\u5185\u7f6e\u51fd\u6570\uff0c\u53ef\u4ee5\u67e5\u770b\u6a21\u5757\u3001\u7c7b\u3001\u51fd\u6570\u7684\u6587\u6863\u5b57\u7b26\u4e32\u3002\u901a\u8fc7\u5b83\uff0c\u4f60\u53ef\u4ee5\u5feb\u901f\u4e86\u89e3\u6a21\u5757\u4e2d\u5305\u542b\u7684\u6240\u6709\u529f\u80fd\u3002<\/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>\u6267\u884c\u4e0a\u8ff0\u4ee3\u7801\u540e\uff0cPython\u4f1a\u8f93\u51fa<code>math<\/code>\u6a21\u5757\u7684\u6240\u6709\u65b9\u6cd5\u548c\u63cf\u8ff0\u3002<code>help()<\/code>\u4e0d\u4ec5\u9002\u7528\u4e8e\u6a21\u5757\uff0c\u4e5f\u9002\u7528\u4e8e\u7c7b\u548c\u51fd\u6570\u3002<\/p>\n<\/p>\n<p><h4>1.2 \u4f7f\u7528 <code>dir()<\/code> \u51fd\u6570<\/h4>\n<\/p>\n<p><p><code>dir()<\/code> \u51fd\u6570\u7528\u4e8e\u5217\u51fa\u5bf9\u8c61\u7684\u6240\u6709\u5c5e\u6027\u548c\u65b9\u6cd5\u3002\u5bf9\u4e8e\u6a21\u5757\uff0c\u5b83\u4f1a\u8fd4\u56de\u8be5\u6a21\u5757\u4e2d\u53ef\u7528\u7684\u6240\u6709\u51fd\u6570\u548c\u53d8\u91cf\u7684\u540d\u79f0\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import math<\/p>\n<p>print(dir(math))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><code>dir()<\/code>\u7684\u8f93\u51fa\u662f\u4e00\u4e2a\u5217\u8868\uff0c\u5305\u542b\u6a21\u5757\u4e2d\u6240\u6709\u7684\u5c5e\u6027\u548c\u65b9\u6cd5\uff0c\u4f46\u4e0d\u5305\u62ec\u8be6\u7ec6\u7684\u63cf\u8ff0\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u67e5\u770b\u6a21\u5757\u7684\u5b98\u65b9\u6587\u6863<\/h3>\n<\/p>\n<p><h4>2.1 \u5b98\u65b9\u6587\u6863<\/h4>\n<\/p>\n<p><p>\u8bb8\u591aPython\u6a21\u5757\u90fd\u6709\u8be6\u7ec6\u7684\u5b98\u65b9\u6587\u6863\uff0c\u5c24\u5176\u662f\u6807\u51c6\u5e93\u548c\u6d41\u884c\u7684\u7b2c\u4e09\u65b9\u5e93\u3002\u5b98\u65b9\u6587\u6863\u901a\u5e38\u662f\u5b66\u4e60\u548c\u7406\u89e3\u6a21\u5757\u529f\u80fd\u7684\u6700\u4f73\u8d44\u6e90\uff0c\u56e0\u4e3a\u5b83\u4eec\u901a\u5e38\u5305\u542b\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>\u6a21\u5757\u6982\u8ff0<\/strong>\uff1a\u63d0\u4f9b\u6a21\u5757\u7684\u603b\u4f53\u8bf4\u660e\u3002<\/li>\n<li><strong>API\u53c2\u8003<\/strong>\uff1a\u5217\u51fa\u6240\u6709\u7684\u7c7b\u3001\u65b9\u6cd5\u3001\u51fd\u6570\u53ca\u5176\u53c2\u6570\u3002<\/li>\n<li><strong>\u793a\u4f8b\u4ee3\u7801<\/strong>\uff1a\u5c55\u793a\u5982\u4f55\u5728\u5b9e\u9645\u9879\u76ee\u4e2d\u4f7f\u7528\u6a21\u5757\u3002<\/li>\n<\/ul>\n<p><p>\u901a\u5e38\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u641c\u7d22\u5f15\u64ce\u641c\u7d22\u201c\u6a21\u5757\u540d + documentation\u201d\u627e\u5230\u76f8\u5173\u6587\u6863\u3002\u4f8b\u5982\uff0c\u641c\u7d22\u201cmath module documentation\u201d\u3002<\/p>\n<\/p>\n<p><h4>2.2 \u5728\u7ebf\u8d44\u6e90<\/h4>\n<\/p>\n<p><p>\u9664\u4e86\u5b98\u65b9\u6587\u6863\uff0c\u8fd8\u6709\u5f88\u591a\u5728\u7ebf\u8d44\u6e90\uff0c\u4f8b\u5982\u6559\u7a0b\u3001\u535a\u5ba2\u548c\u89c6\u9891\uff0c\u53ef\u4ee5\u5e2e\u52a9\u4f60\u7406\u89e3\u6a21\u5757\u7684\u529f\u80fd\u3002\u7f51\u7ad9\u5982Real Python\u3001Stack Overflow\u7b49\uff0c\u90fd\u662f\u5f88\u597d\u7684\u5b66\u4e60\u8d44\u6e90\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u4f7f\u7528IDE\u7684\u81ea\u52a8\u63d0\u793a\u529f\u80fd<\/h3>\n<\/p>\n<p><p>\u73b0\u4ee3IDE\uff08\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff09\u5982PyCharm\u3001VSCode\u7b49\uff0c\u901a\u5e38\u90fd\u6709\u5f3a\u5927\u7684\u81ea\u52a8\u63d0\u793a\u548c\u8865\u5168\u529f\u80fd\u3002<\/p>\n<\/p>\n<p><h4>3.1 \u81ea\u52a8\u8865\u5168<\/h4>\n<\/p>\n<p><p>\u5f53\u4f60\u5728IDE\u4e2d\u8f93\u5165\u6a21\u5757\u540d\u548c\u70b9\u53f7\uff08\u4f8b\u5982<code>math.<\/code>\uff09\u65f6\uff0cIDE\u4f1a\u81ea\u52a8\u5f39\u51fa\u8be5\u6a21\u5757\u4e2d\u53ef\u7528\u7684\u51fd\u6570\u548c\u53d8\u91cf\u5217\u8868\u3002\u8fd9\u4f7f\u5f97\u4f60\u65e0\u9700\u8bb0\u4f4f\u6240\u6709\u7684\u51fd\u6570\u540d\u79f0\uff0c\u975e\u5e38\u65b9\u4fbf\u3002<\/p>\n<\/p>\n<p><h4>3.2 \u5185\u5d4c\u6587\u6863<\/h4>\n<\/p>\n<p><p>\u8bb8\u591aIDE\u8fd8\u652f\u6301\u5185\u5d4c\u6587\u6863\u529f\u80fd\u3002\u5f53\u4f60\u5c06\u9f20\u6807\u60ac\u505c\u5728\u67d0\u4e2a\u51fd\u6570\u6216\u7c7b\u4e0a\u65f6\uff0cIDE\u4f1a\u663e\u793a\u8be5\u51fd\u6570\u6216\u7c7b\u7684\u6587\u6863\u5b57\u7b26\u4e32\u3002\u8fd9\u6837\uff0c\u4f60\u53ef\u4ee5\u7acb\u5373\u83b7\u5f97\u6709\u5173\u8be5\u529f\u80fd\u7684\u8be6\u7ec6\u4fe1\u606f\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u901a\u8fc7\u6e90\u7801\u67e5\u770b<\/h3>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u67e5\u770b\u6a21\u5757\u7684\u6e90\u4ee3\u7801\u53ef\u80fd\u4f1a\u63d0\u4f9b\u66f4\u6df1\u5165\u7684\u7406\u89e3\uff0c\u5c24\u5176\u662f\u5f53\u4f60\u9700\u8981\u7406\u89e3\u4e00\u4e2a\u6a21\u5757\u7684\u5185\u90e8\u5de5\u4f5c\u673a\u5236\u65f6\u3002<\/p>\n<\/p>\n<p><h4>4.1 \u67e5\u770b\u6e90\u7801<\/h4>\n<\/p>\n<p><p>Python\u662f\u5f00\u6e90\u7684\uff0c\u8bb8\u591a\u7b2c\u4e09\u65b9\u5e93\u4e5f\u662f\u5982\u6b64\u3002\u8fd9\u610f\u5473\u7740\u4f60\u53ef\u4ee5\u67e5\u770b\u5b83\u4eec\u7684\u6e90\u4ee3\u7801\u3002\u5bf9\u4e8e\u6807\u51c6\u5e93\uff0cPython\u7684\u5b89\u88c5\u76ee\u5f55\u4e2d\u901a\u5e38\u5305\u542b\u6240\u6709\u7684\u6e90\u7801\u6587\u4ef6\u3002\u5bf9\u4e8e\u7b2c\u4e09\u65b9\u5e93\uff0c\u4f60\u53ef\u4ee5\u5728\u5b83\u4eec\u7684GitHub\u4ed3\u5e93\u4e2d\u627e\u5230\u6e90\u7801\u3002<\/p>\n<\/p>\n<p><p>\u901a\u8fc7\u9605\u8bfb\u6e90\u7801\uff0c\u4f60\u53ef\u4ee5\u4e86\u89e3\u5230\u6a21\u5757\u7684\u5177\u4f53\u5b9e\u73b0\u7ec6\u8282\u3002\u8fd9\u867d\u7136\u9700\u8981\u4e00\u5b9a\u7684\u7f16\u7a0b\u7ecf\u9a8c\uff0c\u4f46\u5bf9\u4e8e\u6df1\u5165\u7406\u89e3\u6a21\u5757\u7684\u529f\u80fd\u975e\u5e38\u6709\u5e2e\u52a9\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001\u793e\u533a\u652f\u6301\u548c\u8bba\u575b<\/h3>\n<\/p>\n<p><p>\u9664\u4e86\u4e0a\u8ff0\u65b9\u6cd5\uff0c\u53c2\u4e0e\u793e\u533a\u8ba8\u8bba\u6216\u5728\u8bba\u575b\u4e0a\u63d0\u95ee\u4e5f\u662f\u4e00\u79cd\u6709\u6548\u7684\u5b66\u4e60\u65b9\u5f0f\u3002Python\u793e\u533a\u975e\u5e38\u6d3b\u8dc3\uff0c\u65e0\u8bba\u662f\u65b0\u624b\u8fd8\u662f\u7ecf\u9a8c\u4e30\u5bcc\u7684\u5f00\u53d1\u8005\uff0c\u90fd\u53ef\u4ee5\u5728\u793e\u533a\u4e2d\u627e\u5230\u6709\u7528\u7684\u4fe1\u606f\u3002<\/p>\n<\/p>\n<p><h4>5.1 \u53c2\u4e0e\u793e\u533a<\/h4>\n<\/p>\n<p><p>\u53c2\u4e0e\u793e\u533a\u6d3b\u52a8\uff0c\u5982Python Meetup\u3001\u5f00\u53d1\u8005\u5927\u4f1a\u7b49\uff0c\u53ef\u4ee5\u4e0e\u5176\u4ed6\u5f00\u53d1\u8005\u4ea4\u6d41\uff0c\u5206\u4eab\u7ecf\u9a8c\u3002\u8fd9\u4e9b\u6d3b\u52a8\u901a\u5e38\u4f1a\u6709\u5173\u4e8ePython\u6a21\u5757\u7684\u4e13\u9898\u8ba8\u8bba\u3002<\/p>\n<\/p>\n<p><h4>5.2 \u5728\u7ebf\u8bba\u575b<\/h4>\n<\/p>\n<p><p>\u5728Stack Overflow\u3001Reddit\u7b49\u8bba\u575b\u4e0a\u63d0\u95ee\uff0c\u901a\u5e38\u53ef\u4ee5\u83b7\u5f97\u5feb\u901f\u800c\u6709\u7528\u7684\u7b54\u590d\u3002\u8bb0\u5f97\u5728\u63d0\u95ee\u65f6\u63d0\u4f9b\u8db3\u591f\u7684\u4fe1\u606f\uff0c\u4ee5\u4fbf\u5176\u4ed6\u4eba\u66f4\u597d\u5730\u7406\u89e3\u4f60\u7684\u95ee\u9898\u3002<\/p>\n<\/p>\n<p><p>\u901a\u8fc7\u8fd9\u4e9b\u65b9\u6cd5\uff0c\u4f60\u53ef\u4ee5\u5168\u9762\u3001\u6df1\u5165\u5730\u4e86\u89e3Python\u6a21\u5757\u7684\u529f\u80fd\uff0c\u4ece\u800c\u66f4\u597d\u5730\u5e94\u7528\u4e8e\u5b9e\u9645\u9879\u76ee\u4e2d\u3002\u65e0\u8bba\u662f\u521d\u5b66\u8005\u8fd8\u662f\u6709\u7ecf\u9a8c\u7684\u5f00\u53d1\u8005\uff0c\u8fd9\u4e9b\u65b9\u6cd5\u90fd\u80fd\u5e2e\u52a9\u4f60\u63d0\u9ad8\u7f16\u7a0b\u6548\u7387\u548c\u4ee3\u7801\u8d28\u91cf\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u67e5\u770b\u6a21\u5757\u7684\u53ef\u7528\u51fd\u6570\u548c\u7c7b\uff1f<\/strong><br \/>\u8981\u67e5\u770b\u4e00\u4e2aPython\u6a21\u5757\u4e2d\u53ef\u7528\u7684\u51fd\u6570\u548c\u7c7b\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u5185\u7f6e\u7684<code>dir()<\/code>\u51fd\u6570\u3002\u8be5\u51fd\u6570\u4f1a\u8fd4\u56de\u4e00\u4e2a\u5305\u542b\u6a21\u5757\u5185\u6240\u6709\u5c5e\u6027\u548c\u65b9\u6cd5\u7684\u5217\u8868\u3002\u6b64\u5916\uff0c\u60a8\u8fd8\u53ef\u4ee5\u4f7f\u7528<code>help()<\/code>\u51fd\u6570\u83b7\u53d6\u66f4\u8be6\u7ec6\u7684\u6587\u6863\u8bf4\u660e\u3002\u8fd9\u4e24\u4e2a\u5de5\u5177\u7ed3\u5408\u4f7f\u7528\uff0c\u53ef\u4ee5\u8ba9\u60a8\u5feb\u901f\u4e86\u89e3\u6a21\u5757\u7684\u529f\u80fd\u3002<\/p>\n<p><strong>\u4f7f\u7528<code>help()<\/code>\u51fd\u6570\u65f6\uff0c\u6211\u8be5\u5982\u4f55\u67e5\u627e\u7279\u5b9a\u6a21\u5757\u7684\u4fe1\u606f\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u8f93\u5165<code>help(&#39;\u6a21\u5757\u540d&#39;)<\/code>\u6765\u83b7\u53d6\u6709\u5173\u7279\u5b9a\u6a21\u5757\u7684\u8be6\u7ec6\u4fe1\u606f\u3002\u8fd9\u5c06\u663e\u793a\u6a21\u5757\u7684\u6587\u6863\u5b57\u7b26\u4e32\uff0c\u5305\u62ec\u53ef\u7528\u7684\u51fd\u6570\u3001\u7c7b\u3001\u65b9\u6cd5\u4ee5\u53ca\u5b83\u4eec\u7684\u53c2\u6570\u548c\u8fd4\u56de\u503c\u3002\u8fd9\u662f\u7406\u89e3\u6a21\u5757\u529f\u80fd\u7684\u4e00\u4e2a\u6709\u6548\u65b9\u5f0f\u3002<\/p>\n<p><strong>\u5982\u4f55\u67e5\u770b\u67d0\u4e2a\u6a21\u5757\u7684\u6587\u6863\u4ee5\u83b7\u53d6\u66f4\u591a\u793a\u4f8b\u548c\u7528\u6cd5\uff1f<\/strong><br \/>\u8bb8\u591aPython\u6a21\u5757\u90fd\u6709\u5b98\u65b9\u6587\u6863\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u8bbf\u95ee\u76f8\u5e94\u7684\u5b98\u65b9\u7f51\u7ad9\u6216\u6587\u6863\u9875\u9762\u6765\u83b7\u53d6\u8be6\u7ec6\u7684\u7528\u6cd5\u548c\u793a\u4f8b\u3002\u5728\u6a21\u5757\u7684GitHub\u9875\u9762\u6216PyPI\uff08Python Package Index\uff09\u4e0a\uff0c\u901a\u5e38\u4e5f\u53ef\u4ee5\u627e\u5230\u4f7f\u7528\u793a\u4f8b\u548c\u5e38\u89c1\u95ee\u9898\u7684\u89e3\u7b54\uff0c\u8fd9\u80fd\u5e2e\u52a9\u60a8\u66f4\u597d\u5730\u7406\u89e3\u6a21\u5757\u7684\u529f\u80fd\u548c\u5e94\u7528\u573a\u666f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"PYTHON\u5982\u4f55\u67e5\u770b\u6a21\u5757\u529f\u80fd \u5728Python\u4e2d\uff0c\u67e5\u770b\u6a21\u5757\u529f\u80fd\u7684\u65b9\u6cd5\u6709\u5f88\u591a\uff0c\u5305\u62ec\u4f7f\u7528\u5185\u7f6e\u51fd\u6570\u3001\u67e5\u770b\u6a21\u5757\u7684\u5b98\u65b9\u6587\u6863 [&hellip;]","protected":false},"author":3,"featured_media":1013889,"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\/1013883"}],"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=1013883"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1013883\/revisions"}],"predecessor-version":[{"id":1013891,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1013883\/revisions\/1013891"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1013889"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1013883"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1013883"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1013883"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}