{"id":1079995,"date":"2025-01-08T12:26:05","date_gmt":"2025-01-08T04:26:05","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1079995.html"},"modified":"2025-01-08T12:26:07","modified_gmt":"2025-01-08T04:26:07","slug":"%e5%a6%82%e4%bd%95%e7%9f%a5%e9%81%93python%e5%86%85%e7%bd%ae%e6%a8%a1%e5%9d%97%e6%9c%89%e5%93%aa%e4%ba%9b%e5%8a%9f%e8%83%bd-2","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1079995.html","title":{"rendered":"\u5982\u4f55\u77e5\u9053python\u5185\u7f6e\u6a21\u5757\u6709\u54ea\u4e9b\u529f\u80fd"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24182744\/2c2297bc-9749-434f-a9fd-93cb05d0fea2.webp\" alt=\"\u5982\u4f55\u77e5\u9053python\u5185\u7f6e\u6a21\u5757\u6709\u54ea\u4e9b\u529f\u80fd\" \/><\/p>\n<p><p> <strong>\u8981\u77e5\u9053Python\u5185\u7f6e\u6a21\u5757\u6709\u54ea\u4e9b\u529f\u80fd\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\uff1a\u67e5\u770b\u5b98\u65b9\u6587\u6863\u3001\u4f7f\u7528help()\u51fd\u6570\u3001dir()\u51fd\u6570\u3001\u67e5\u770b\u6e90\u7801\u3002<\/strong>\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u8fd9\u4e9b\u65b9\u6cd5\uff0c\u5e76\u9010\u4e00\u5c55\u5f00\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u67e5\u770b\u5b98\u65b9\u6587\u6863<\/p>\n<\/p>\n<p><p>Python\u5b98\u65b9\u6587\u6863\u662f\u4e86\u89e3Python\u5185\u7f6e\u6a21\u5757\u529f\u80fd\u7684\u6700\u4f73\u9014\u5f84\u3002\u5728\u5b98\u65b9\u6587\u6863\u4e2d\uff0c\u4e0d\u4ec5\u53ef\u4ee5\u627e\u5230\u6a21\u5757\u7684\u8be6\u7ec6\u63cf\u8ff0\uff0c\u8fd8\u80fd\u770b\u5230\u6a21\u5757\u7684\u6240\u6709\u51fd\u6570\u3001\u7c7b\u548c\u4f7f\u7528\u793a\u4f8b\u3002Python\u5b98\u65b9\u6587\u6863\u7684\u5730\u5740\u662f\uff1a<a href=\"https:\/\/docs.python.org\/3\/library\/\">https:\/\/docs.python.org\/3\/library\/<\/a><\/p>\n<\/p>\n<p><p>\u5728\u5b98\u65b9\u6587\u6863\u4e2d\uff0c\u4f60\u53ef\u4ee5\u6309\u7167\u6a21\u5757\u540d\u79f0\u67e5\u627e\u5bf9\u5e94\u7684\u6a21\u5757\uff0c\u9605\u8bfb\u5176\u529f\u80fd\u4ecb\u7ecd\u548c\u4f7f\u7528\u65b9\u6cd5\u3002\u4f8b\u5982\uff0c\u8981\u4e86\u89e3<code>os<\/code>\u6a21\u5757\uff0c\u53ef\u4ee5\u5728\u6587\u6863\u7684\u7d22\u5f15\u9875\u4e2d\u627e\u5230<code>os<\/code>\u6a21\u5757\uff0c\u7136\u540e\u70b9\u51fb\u8fdb\u5165\u67e5\u770b\u8be6\u7ec6\u4fe1\u606f\u3002<\/p>\n<\/p>\n<p><p>\u5b98\u65b9\u6587\u6863\u4e0d\u4ec5\u5305\u542b\u6a21\u5757\u7684\u529f\u80fd\u4ecb\u7ecd\uff0c\u8fd8\u63d0\u4f9b\u4e86\u793a\u4f8b\u4ee3\u7801\uff0c\u5e2e\u52a9\u4f60\u66f4\u597d\u5730\u7406\u89e3\u548c\u4f7f\u7528\u8be5\u6a21\u5757\u3002\u6b64\u5916\uff0c\u5b98\u65b9\u6587\u6863\u8fd8\u4f1a\u6301\u7eed\u66f4\u65b0\uff0c\u786e\u4fdd\u4f60\u4e86\u89e3\u6700\u65b0\u7684\u529f\u80fd\u548c\u6539\u8fdb\u3002<\/p>\n<\/p>\n<p><p>\u4e8c\u3001\u4f7f\u7528help()\u51fd\u6570<\/p>\n<\/p>\n<p><p>Python\u5185\u7f6e\u7684<code>help()<\/code>\u51fd\u6570\u662f\u4e00\u4e2a\u975e\u5e38\u6709\u7528\u7684\u5de5\u5177\uff0c\u53ef\u4ee5\u5e2e\u52a9\u4f60\u4e86\u89e3\u6a21\u5757\u3001\u7c7b\u3001\u51fd\u6570\u7684\u8be6\u7ec6\u4fe1\u606f\u3002\u4f60\u53ea\u9700\u8981\u5728Python\u89e3\u91ca\u5668\u4e2d\u8f93\u5165<code>help(\u6a21\u5757\u540d\u79f0)<\/code>\uff0c\u5c31\u53ef\u4ee5\u770b\u5230\u8be5\u6a21\u5757\u7684\u6587\u6863\u8bf4\u660e\u3002<\/p>\n<\/p>\n<p><p>\u4f8b\u5982\uff0c\u8981\u4e86\u89e3<code>math<\/code>\u6a21\u5757\u7684\u529f\u80fd\uff0c\u53ef\u4ee5\u5728Python\u89e3\u91ca\u5668\u4e2d\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<code>math<\/code>\u6a21\u5757\u7684\u8be6\u7ec6\u6587\u6863\uff0c\u5305\u62ec\u6240\u6709\u53ef\u7528\u7684\u51fd\u6570\u53ca\u5176\u63cf\u8ff0\u3002\u901a\u8fc7\u9605\u8bfb\u8fd9\u4e9b\u6587\u6863\uff0c\u4f60\u53ef\u4ee5\u5feb\u901f\u4e86\u89e3\u6a21\u5757\u7684\u529f\u80fd\u548c\u7528\u6cd5\u3002<\/p>\n<\/p>\n<p><p>\u4e09\u3001dir()\u51fd\u6570<\/p>\n<\/p>\n<p><p><code>dir()<\/code>\u51fd\u6570\u53ef\u4ee5\u5217\u51fa\u6a21\u5757\u4e2d\u7684\u6240\u6709\u5c5e\u6027\u548c\u65b9\u6cd5\u3002\u867d\u7136<code>dir()<\/code>\u51fd\u6570\u4e0d\u4f1a\u63d0\u4f9b\u8be6\u7ec6\u7684\u6587\u6863\u8bf4\u660e\uff0c\u4f46\u5b83\u53ef\u4ee5\u5e2e\u52a9\u4f60\u5feb\u901f\u6d4f\u89c8\u6a21\u5757\u4e2d\u7684\u6240\u6709\u6210\u5458\u3002<\/p>\n<\/p>\n<p><p>\u4f8b\u5982\uff0c\u8981\u67e5\u770b<code>sys<\/code>\u6a21\u5757\u4e2d\u7684\u6240\u6709\u5c5e\u6027\u548c\u65b9\u6cd5\uff0c\u53ef\u4ee5\u5728Python\u89e3\u91ca\u5668\u4e2d\u8f93\u5165\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import sys<\/p>\n<p>dir(sys)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u8fd4\u56de\u4e00\u4e2a\u5305\u542b<code>sys<\/code>\u6a21\u5757\u4e2d\u6240\u6709\u5c5e\u6027\u548c\u65b9\u6cd5\u540d\u79f0\u7684\u5217\u8868\u3002\u4f60\u53ef\u4ee5\u6839\u636e\u8fd9\u4e9b\u540d\u79f0\uff0c\u518d\u4f7f\u7528<code>help()<\/code>\u51fd\u6570\u83b7\u53d6\u5177\u4f53\u7684\u529f\u80fd\u8bf4\u660e\u3002<\/p>\n<\/p>\n<p><p>\u56db\u3001\u67e5\u770b\u6e90\u7801<\/p>\n<\/p>\n<p><p>\u5bf9\u4e8e\u4e00\u4e9b\u590d\u6742\u7684\u6a21\u5757\uff0c\u5982\u679c\u4f60\u60f3\u6df1\u5165\u4e86\u89e3\u5176\u5b9e\u73b0\u7ec6\u8282\uff0c\u53ef\u4ee5\u67e5\u770b\u6a21\u5757\u7684\u6e90\u7801\u3002Python\u7684\u6807\u51c6\u5e93\u6e90\u7801\u90fd\u662f\u516c\u5f00\u7684\uff0c\u4f60\u53ef\u4ee5\u5728Python\u7684\u5b89\u88c5\u76ee\u5f55\u4e2d\u627e\u5230\u8fd9\u4e9b\u6e90\u7801\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><p>\u4f8b\u5982\uff0c\u8981\u67e5\u770b<code>json<\/code>\u6a21\u5757\u7684\u6e90\u7801\uff0c\u53ef\u4ee5\u5728Python\u5b89\u88c5\u76ee\u5f55\u7684<code>Lib\/json<\/code>\u6587\u4ef6\u5939\u4e2d\u627e\u5230\u76f8\u5e94\u7684\u6e90\u7801\u6587\u4ef6\u3002\u901a\u8fc7\u9605\u8bfb\u6e90\u7801\uff0c\u4f60\u53ef\u4ee5\u4e86\u89e3\u6a21\u5757\u7684\u5b9e\u73b0\u539f\u7406\u548c\u5185\u90e8\u903b\u8f91\u3002<\/p>\n<\/p>\n<p><p>\u4e94\u3001\u5e38\u89c1\u5185\u7f6e\u6a21\u5757\u529f\u80fd\u4ecb\u7ecd<\/p>\n<\/p>\n<p><p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u4ecb\u7ecd\u4e00\u4e9b\u5e38\u89c1\u7684Python\u5185\u7f6e\u6a21\u5757\u53ca\u5176\u4e3b\u8981\u529f\u80fd\u3002<\/p>\n<\/p>\n<p><h3>1\u3001os\u6a21\u5757<\/h3>\n<\/p>\n<p><p><code>os<\/code>\u6a21\u5757\u63d0\u4f9b\u4e86\u4e0e\u64cd\u4f5c\u7cfb\u7edf\u4ea4\u4e92\u7684\u529f\u80fd\uff0c\u5305\u62ec\u6587\u4ef6\u548c\u76ee\u5f55\u64cd\u4f5c\u3001\u73af\u5883\u53d8\u91cf\u7ba1\u7406\u3001\u8fdb\u7a0b\u7ba1\u7406\u7b49\u3002\u5e38\u7528\u529f\u80fd\u5305\u62ec\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>\u6587\u4ef6\u548c\u76ee\u5f55\u64cd\u4f5c<\/strong>\uff1a<code>os.path<\/code>\u5b50\u6a21\u5757\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u51fd\u6570\u7528\u4e8e\u6587\u4ef6\u548c\u76ee\u5f55\u7684\u64cd\u4f5c\uff0c\u5982<code>os.path.join()<\/code>\u3001<code>os.path.exists()<\/code>\u7b49\u3002<\/li>\n<li><strong>\u73af\u5883\u53d8\u91cf\u7ba1\u7406<\/strong>\uff1a<code>os.environ<\/code>\u53ef\u4ee5\u83b7\u53d6\u548c\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\u3002<\/li>\n<li><strong>\u8fdb\u7a0b\u7ba1\u7406<\/strong>\uff1a<code>os.system()<\/code>\u53ef\u4ee5\u6267\u884c\u7cfb\u7edf\u547d\u4ee4\uff0c<code>os.popen()<\/code>\u53ef\u4ee5\u6253\u5f00\u4e00\u4e2a\u7ba1\u9053\u4e0e\u5b50\u8fdb\u7a0b\u901a\u4fe1\u3002<\/li>\n<\/ul>\n<p><h3>2\u3001sys\u6a21\u5757<\/h3>\n<\/p>\n<p><p><code>sys<\/code>\u6a21\u5757\u63d0\u4f9b\u4e86\u4e0ePython\u89e3\u91ca\u5668\u76f8\u5173\u7684\u529f\u80fd\uff0c\u5305\u62ec\u547d\u4ee4\u884c\u53c2\u6570\u3001\u6807\u51c6\u8f93\u5165\u8f93\u51fa\u3001\u6a21\u5757\u641c\u7d22\u8def\u5f84\u7b49\u3002\u5e38\u7528\u529f\u80fd\u5305\u62ec\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>\u547d\u4ee4\u884c\u53c2\u6570<\/strong>\uff1a<code>sys.argv<\/code>\u53ef\u4ee5\u83b7\u53d6\u547d\u4ee4\u884c\u53c2\u6570\u5217\u8868\u3002<\/li>\n<li><strong>\u6807\u51c6\u8f93\u5165\u8f93\u51fa<\/strong>\uff1a<code>sys.stdin<\/code>\u3001<code>sys.stdout<\/code>\u3001<code>sys.stderr<\/code>\u5206\u522b\u8868\u793a\u6807\u51c6\u8f93\u5165\u3001\u8f93\u51fa\u548c\u9519\u8bef\u6d41\u3002<\/li>\n<li><strong>\u6a21\u5757\u641c\u7d22\u8def\u5f84<\/strong>\uff1a<code>sys.path<\/code>\u662f\u4e00\u4e2a\u5217\u8868\uff0c\u5305\u542b\u4e86\u89e3\u91ca\u5668\u5728\u5bfc\u5165\u6a21\u5757\u65f6\u641c\u7d22\u7684\u8def\u5f84\u3002<\/li>\n<\/ul>\n<p><h3>3\u3001math\u6a21\u5757<\/h3>\n<\/p>\n<p><p><code>math<\/code>\u6a21\u5757\u63d0\u4f9b\u4e86\u5e38\u7528\u7684\u6570\u5b66\u51fd\u6570\u548c\u5e38\u6570\u3002\u5e38\u7528\u529f\u80fd\u5305\u62ec\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>\u6570\u5b66\u51fd\u6570<\/strong>\uff1a\u5982<code>math.sqrt()<\/code>\u8ba1\u7b97\u5e73\u65b9\u6839\uff0c<code>math.sin()<\/code>\u8ba1\u7b97\u6b63\u5f26\u503c\uff0c<code>math.exp()<\/code>\u8ba1\u7b97\u6307\u6570\u503c\u7b49\u3002<\/li>\n<li><strong>\u6570\u5b66\u5e38\u6570<\/strong>\uff1a\u5982<code>math.pi<\/code>\u8868\u793a\u5706\u5468\u7387\uff0c<code>math.e<\/code>\u8868\u793a\u81ea\u7136\u5bf9\u6570\u7684\u5e95\u6570\u3002<\/li>\n<\/ul>\n<p><h3>4\u3001json\u6a21\u5757<\/h3>\n<\/p>\n<p><p><code>json<\/code>\u6a21\u5757\u63d0\u4f9b\u4e86\u5904\u7406JSON\u6570\u636e\u7684\u529f\u80fd\u3002\u5e38\u7528\u529f\u80fd\u5305\u62ec\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>\u5e8f\u5217\u5316<\/strong>\uff1a<code>json.dumps()<\/code>\u53ef\u4ee5\u5c06Python\u5bf9\u8c61\u8f6c\u6362\u4e3aJSON\u5b57\u7b26\u4e32\u3002<\/li>\n<li><strong>\u53cd\u5e8f\u5217\u5316<\/strong>\uff1a<code>json.loads()<\/code>\u53ef\u4ee5\u5c06JSON\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3aPython\u5bf9\u8c61\u3002<\/li>\n<li><strong>\u6587\u4ef6\u64cd\u4f5c<\/strong>\uff1a<code>json.dump()<\/code>\u548c<code>json.load()<\/code>\u53ef\u4ee5\u5206\u522b\u5c06Python\u5bf9\u8c61\u5199\u5165JSON\u6587\u4ef6\u548c\u4eceJSON\u6587\u4ef6\u8bfb\u53d6\u6570\u636e\u3002<\/li>\n<\/ul>\n<p><h3>5\u3001datetime\u6a21\u5757<\/h3>\n<\/p>\n<p><p><code>datetime<\/code>\u6a21\u5757\u63d0\u4f9b\u4e86\u5904\u7406\u65e5\u671f\u548c\u65f6\u95f4\u7684\u529f\u80fd\u3002\u5e38\u7528\u529f\u80fd\u5305\u62ec\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>\u83b7\u53d6\u5f53\u524d\u65e5\u671f\u548c\u65f6\u95f4<\/strong>\uff1a<code>datetime.datetime.now()<\/code>\u53ef\u4ee5\u83b7\u53d6\u5f53\u524d\u7684\u65e5\u671f\u548c\u65f6\u95f4\u3002<\/li>\n<li><strong>\u65e5\u671f\u548c\u65f6\u95f4\u7684\u8ba1\u7b97<\/strong>\uff1a\u53ef\u4ee5\u4f7f\u7528<code>timedelta<\/code>\u7c7b\u8fdb\u884c\u65e5\u671f\u548c\u65f6\u95f4\u7684\u52a0\u51cf\u8fd0\u7b97\u3002<\/li>\n<li><strong>\u65e5\u671f\u548c\u65f6\u95f4\u7684\u683c\u5f0f\u5316<\/strong>\uff1a\u53ef\u4ee5\u4f7f\u7528<code>strftime()<\/code>\u65b9\u6cd5\u5c06\u65e5\u671f\u548c\u65f6\u95f4\u683c\u5f0f\u5316\u4e3a\u5b57\u7b26\u4e32\u3002<\/li>\n<\/ul>\n<p><h3>6\u3001re\u6a21\u5757<\/h3>\n<\/p>\n<p><p><code>re<\/code>\u6a21\u5757\u63d0\u4f9b\u4e86\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u652f\u6301\u3002\u5e38\u7528\u529f\u80fd\u5305\u62ec\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>\u6a21\u5f0f\u5339\u914d<\/strong>\uff1a<code>re.match()<\/code>\u53ef\u4ee5\u4ece\u5b57\u7b26\u4e32\u7684\u5f00\u59cb\u4f4d\u7f6e\u5339\u914d\u6a21\u5f0f\uff0c<code>re.search()<\/code>\u53ef\u4ee5\u5728\u6574\u4e2a\u5b57\u7b26\u4e32\u4e2d\u641c\u7d22\u6a21\u5f0f\u3002<\/li>\n<li><strong>\u66ff\u6362<\/strong>\uff1a<code>re.sub()<\/code>\u53ef\u4ee5\u66ff\u6362\u5339\u914d\u7684\u5b57\u7b26\u4e32\u3002<\/li>\n<li><strong>\u5206\u5272<\/strong>\uff1a<code>re.split()<\/code>\u53ef\u4ee5\u6309\u7167\u6b63\u5219\u8868\u8fbe\u5f0f\u5206\u5272\u5b57\u7b26\u4e32\u3002<\/li>\n<\/ul>\n<p><h3>7\u3001urllib\u6a21\u5757<\/h3>\n<\/p>\n<p><p><code>urllib<\/code>\u6a21\u5757\u63d0\u4f9b\u4e86\u5904\u7406URL\u548c\u8fdb\u884cHTTP\u8bf7\u6c42\u7684\u529f\u80fd\u3002\u5e38\u7528\u529f\u80fd\u5305\u62ec\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>URL\u89e3\u6790<\/strong>\uff1a<code>urllib.parse<\/code>\u5b50\u6a21\u5757\u63d0\u4f9b\u4e86URL\u7684\u89e3\u6790\u3001\u6784\u5efa\u548c\u7f16\u7801\u529f\u80fd\u3002<\/li>\n<li><strong>HTTP\u8bf7\u6c42<\/strong>\uff1a<code>urllib.request<\/code>\u5b50\u6a21\u5757\u63d0\u4f9b\u4e86\u53d1\u9001HTTP\u8bf7\u6c42\u548c\u5904\u7406\u54cd\u5e94\u7684\u529f\u80fd\u3002<\/li>\n<\/ul>\n<p><h3>8\u3001collections\u6a21\u5757<\/h3>\n<\/p>\n<p><p><code>collections<\/code>\u6a21\u5757\u63d0\u4f9b\u4e86\u9ad8\u7ea7\u7684\u6570\u636e\u7ed3\u6784\uff0c\u5982<code>namedtuple<\/code>\u3001<code>deque<\/code>\u3001<code>Counter<\/code>\u3001<code>OrderedDict<\/code>\u7b49\u3002\u5e38\u7528\u529f\u80fd\u5305\u62ec\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>namedtuple<\/strong>\uff1a\u53ef\u4ee5\u521b\u5efa\u5177\u540d\u5143\u7ec4\uff0c\u5177\u540d\u5143\u7ec4\u53ef\u4ee5\u50cf\u666e\u901a\u5143\u7ec4\u4e00\u6837\u4f7f\u7528\uff0c\u540c\u65f6\u53ef\u4ee5\u901a\u8fc7\u5c5e\u6027\u540d\u79f0\u8bbf\u95ee\u5143\u7d20\u3002<\/li>\n<li><strong>deque<\/strong>\uff1a\u53cc\u7aef\u961f\u5217\uff0c\u652f\u6301\u9ad8\u6548\u7684\u4ece\u4e24\u7aef\u6dfb\u52a0\u548c\u5220\u9664\u5143\u7d20\u7684\u64cd\u4f5c\u3002<\/li>\n<li><strong>Counter<\/strong>\uff1a\u8ba1\u6570\u5668\uff0c\u7528\u4e8e\u8ba1\u6570\u53ef\u54c8\u5e0c\u5bf9\u8c61\u7684\u51fa\u73b0\u6b21\u6570\u3002<\/li>\n<li><strong>OrderedDict<\/strong>\uff1a\u6709\u5e8f\u5b57\u5178\uff0c\u8bb0\u5f55\u4e86\u5143\u7d20\u63d2\u5165\u7684\u987a\u5e8f\u3002<\/li>\n<\/ul>\n<p><h3>9\u3001itertools\u6a21\u5757<\/h3>\n<\/p>\n<p><p><code>itertools<\/code>\u6a21\u5757\u63d0\u4f9b\u4e86\u9ad8\u6548\u7684\u8fed\u4ee3\u5668\u5de5\u5177\u3002\u5e38\u7528\u529f\u80fd\u5305\u62ec\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>\u751f\u6210\u5668\u51fd\u6570<\/strong>\uff1a\u5982<code>itertools.count()<\/code>\u3001<code>itertools.cycle()<\/code>\u3001<code>itertools.repeat()<\/code>\u7b49\u3002<\/li>\n<li><strong>\u7ec4\u5408\u51fd\u6570<\/strong>\uff1a\u5982<code>itertools.combinations()<\/code>\u3001<code>itertools.permutations()<\/code>\u3001<code>itertools.product()<\/code>\u7b49\u3002<\/li>\n<li><strong>\u8fc7\u6ee4\u51fd\u6570<\/strong>\uff1a\u5982<code>itertools.filterfalse()<\/code>\u3001<code>itertools.compress()<\/code>\u7b49\u3002<\/li>\n<\/ul>\n<p><h3>10\u3001functools\u6a21\u5757<\/h3>\n<\/p>\n<p><p><code>functools<\/code>\u6a21\u5757\u63d0\u4f9b\u4e86\u9ad8\u9636\u51fd\u6570\u548c\u53ef\u8c03\u7528\u5bf9\u8c61\u7684\u5de5\u5177\u3002\u5e38\u7528\u529f\u80fd\u5305\u62ec\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>lru_cache<\/strong>\uff1a\u88c5\u9970\u5668\uff0c\u7528\u4e8e\u7f13\u5b58\u51fd\u6570\u7684\u8fd4\u56de\u503c\uff0c\u63d0\u5347\u6027\u80fd\u3002<\/li>\n<li><strong>partial<\/strong>\uff1a\u51fd\u6570\u90e8\u5206\u5e94\u7528\uff0c\u53ef\u4ee5\u56fa\u5b9a\u51fd\u6570\u7684\u90e8\u5206\u53c2\u6570\uff0c\u8fd4\u56de\u4e00\u4e2a\u65b0\u7684\u51fd\u6570\u3002<\/li>\n<li><strong>reduce<\/strong>\uff1a\u5bf9\u5e8f\u5217\u4e2d\u7684\u5143\u7d20\u8fdb\u884c\u7d2f\u79ef\u8ba1\u7b97\u3002<\/li>\n<\/ul>\n<p><h3>11\u3001random\u6a21\u5757<\/h3>\n<\/p>\n<p><p><code>random<\/code>\u6a21\u5757\u63d0\u4f9b\u4e86\u751f\u6210\u968f\u673a\u6570\u7684\u529f\u80fd\u3002\u5e38\u7528\u529f\u80fd\u5305\u62ec\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>\u751f\u6210\u968f\u673a\u6570<\/strong>\uff1a\u5982<code>random.random()<\/code>\u751f\u6210\u4e00\u4e2a0\u52301\u4e4b\u95f4\u7684\u968f\u673a\u6d6e\u70b9\u6570\uff0c<code>random.randint()<\/code>\u751f\u6210\u4e00\u4e2a\u6307\u5b9a\u8303\u56f4\u5185\u7684\u968f\u673a\u6574\u6570\u3002<\/li>\n<li><strong>\u968f\u673a\u9009\u62e9<\/strong>\uff1a\u5982<code>random.choice()<\/code>\u4ece\u5e8f\u5217\u4e2d\u968f\u673a\u9009\u62e9\u4e00\u4e2a\u5143\u7d20\uff0c<code>random.sample()<\/code>\u4ece\u5e8f\u5217\u4e2d\u968f\u673a\u9009\u62e9\u6307\u5b9a\u6570\u91cf\u7684\u5143\u7d20\u3002<\/li>\n<li><strong>\u968f\u673a\u6253\u4e71<\/strong>\uff1a<code>random.shuffle()<\/code>\u53ef\u4ee5\u5c06\u5e8f\u5217\u4e2d\u7684\u5143\u7d20\u968f\u673a\u6253\u4e71\u3002<\/li>\n<\/ul>\n<p><h3>12\u3001csv\u6a21\u5757<\/h3>\n<\/p>\n<p><p><code>csv<\/code>\u6a21\u5757\u63d0\u4f9b\u4e86\u8bfb\u5199CSV\u6587\u4ef6\u7684\u529f\u80fd\u3002\u5e38\u7528\u529f\u80fd\u5305\u62ec\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>\u8bfb\u53d6CSV\u6587\u4ef6<\/strong>\uff1a<code>csv.reader()<\/code>\u53ef\u4ee5\u8bfb\u53d6CSV\u6587\u4ef6\uff0c\u8fd4\u56de\u4e00\u4e2a\u8fed\u4ee3\u5668\uff0c\u6bcf\u6b21\u8fed\u4ee3\u8fd4\u56de\u4e00\u884c\u6570\u636e\u3002<\/li>\n<li><strong>\u5199\u5165CSV\u6587\u4ef6<\/strong>\uff1a<code>csv.writer()<\/code>\u53ef\u4ee5\u5199\u5165CSV\u6587\u4ef6\uff0c\u63d0\u4f9b<code>writerow()<\/code>\u548c<code>writerows()<\/code>\u65b9\u6cd5\u5206\u522b\u5199\u5165\u5355\u884c\u548c\u591a\u884c\u6570\u636e\u3002<\/li>\n<\/ul>\n<p><h3>13\u3001sqlite3\u6a21\u5757<\/h3>\n<\/p>\n<p><p><code>sqlite3<\/code>\u6a21\u5757\u63d0\u4f9b\u4e86SQLite\u6570\u636e\u5e93\u7684\u652f\u6301\u3002\u5e38\u7528\u529f\u80fd\u5305\u62ec\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>\u8fde\u63a5\u6570\u636e\u5e93<\/strong>\uff1a<code>sqlite3.connect()<\/code>\u53ef\u4ee5\u8fde\u63a5\u5230\u4e00\u4e2aSQLite\u6570\u636e\u5e93\uff0c\u8fd4\u56de\u4e00\u4e2a\u8fde\u63a5\u5bf9\u8c61\u3002<\/li>\n<li><strong>\u6267\u884cSQL\u8bed\u53e5<\/strong>\uff1a\u8fde\u63a5\u5bf9\u8c61\u7684<code>execute()<\/code>\u65b9\u6cd5\u53ef\u4ee5\u6267\u884cSQL\u8bed\u53e5\uff0c\u8fd4\u56de\u4e00\u4e2a\u6e38\u6807\u5bf9\u8c61\u3002<\/li>\n<li><strong>\u4e8b\u52a1\u7ba1\u7406<\/strong>\uff1a\u8fde\u63a5\u5bf9\u8c61\u7684<code>commit()<\/code>\u548c<code>rollback()<\/code>\u65b9\u6cd5\u53ef\u4ee5\u63d0\u4ea4\u548c\u56de\u6eda\u4e8b\u52a1\u3002<\/li>\n<\/ul>\n<p><h3>14\u3001logging\u6a21\u5757<\/h3>\n<\/p>\n<p><p><code>logging<\/code>\u6a21\u5757\u63d0\u4f9b\u4e86\u7075\u6d3b\u7684\u65e5\u5fd7\u8bb0\u5f55\u529f\u80fd\u3002\u5e38\u7528\u529f\u80fd\u5305\u62ec\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>\u914d\u7f6e\u65e5\u5fd7\u8bb0\u5f55\u5668<\/strong>\uff1a<code>logging.basicConfig()<\/code>\u53ef\u4ee5\u914d\u7f6e\u65e5\u5fd7\u8bb0\u5f55\u5668\u7684\u57fa\u672c\u5c5e\u6027\uff0c\u5982\u65e5\u5fd7\u7ea7\u522b\u3001\u8f93\u51fa\u683c\u5f0f\u548c\u8f93\u51fa\u4f4d\u7f6e\u3002<\/li>\n<li><strong>\u8bb0\u5f55\u65e5\u5fd7<\/strong>\uff1a\u65e5\u5fd7\u8bb0\u5f55\u5668\u63d0\u4f9b\u4e86<code>debug()<\/code>\u3001<code>info()<\/code>\u3001<code>warning()<\/code>\u3001<code>error()<\/code>\u548c<code>critical()<\/code>\u65b9\u6cd5\u7528\u4e8e\u8bb0\u5f55\u4e0d\u540c\u7ea7\u522b\u7684\u65e5\u5fd7\u3002<\/li>\n<li><strong>\u81ea\u5b9a\u4e49\u65e5\u5fd7\u5904\u7406\u5668<\/strong>\uff1a\u53ef\u4ee5\u521b\u5efa\u81ea\u5b9a\u4e49\u7684\u65e5\u5fd7\u5904\u7406\u5668\uff0c\u5c06\u65e5\u5fd7\u8f93\u51fa\u5230\u6587\u4ef6\u3001\u7f51\u7edc\u3001\u90ae\u4ef6\u7b49\u4e0d\u540c\u4f4d\u7f6e\u3002<\/li>\n<\/ul>\n<p><h3>15\u3001threading\u6a21\u5757<\/h3>\n<\/p>\n<p><p><code>threading<\/code>\u6a21\u5757\u63d0\u4f9b\u4e86\u7ebf\u7a0b\u7684\u652f\u6301\u3002\u5e38\u7528\u529f\u80fd\u5305\u62ec\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>\u521b\u5efa\u7ebf\u7a0b<\/strong>\uff1a<code>threading.Thread()<\/code>\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u7ebf\u7a0b\u5bf9\u8c61\uff0c\u7ebf\u7a0b\u5bf9\u8c61\u7684<code>start()<\/code>\u65b9\u6cd5\u53ef\u4ee5\u542f\u52a8\u7ebf\u7a0b\u3002<\/li>\n<li><strong>\u7ebf\u7a0b\u540c\u6b65<\/strong>\uff1a<code>threading.Lock()<\/code>\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u9501\u5bf9\u8c61\uff0c\u7528\u4e8e\u7ebf\u7a0b\u95f4\u7684\u540c\u6b65\uff0c\u907f\u514d\u7ade\u4e89\u6761\u4ef6\u3002<\/li>\n<li><strong>\u7ebf\u7a0b\u901a\u4fe1<\/strong>\uff1a<code>threading.Event()<\/code>\u3001<code>threading.Condition()<\/code>\u7b49\u53ef\u4ee5\u7528\u4e8e\u7ebf\u7a0b\u95f4\u7684\u901a\u4fe1\u548c\u534f\u8c03\u3002<\/li>\n<\/ul>\n<p><h3>16\u3001multiprocessing\u6a21\u5757<\/h3>\n<\/p>\n<p><p><code>multiprocessing<\/code>\u6a21\u5757\u63d0\u4f9b\u4e86\u591a\u8fdb\u7a0b\u7684\u652f\u6301\u3002\u5e38\u7528\u529f\u80fd\u5305\u62ec\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>\u521b\u5efa\u8fdb\u7a0b<\/strong>\uff1a<code>multiprocessing.Process()<\/code>\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u8fdb\u7a0b\u5bf9\u8c61\uff0c\u8fdb\u7a0b\u5bf9\u8c61\u7684<code>start()<\/code>\u65b9\u6cd5\u53ef\u4ee5\u542f\u52a8\u8fdb\u7a0b\u3002<\/li>\n<li><strong>\u8fdb\u7a0b\u95f4\u901a\u4fe1<\/strong>\uff1a<code>multiprocessing.Queue()<\/code>\u3001<code>multiprocessing.Pipe()<\/code>\u7b49\u53ef\u4ee5\u7528\u4e8e\u8fdb\u7a0b\u95f4\u7684\u901a\u4fe1\u3002<\/li>\n<li><strong>\u8fdb\u7a0b\u540c\u6b65<\/strong>\uff1a<code>multiprocessing.Lock()<\/code>\u3001<code>multiprocessing.Semaphore()<\/code>\u7b49\u53ef\u4ee5\u7528\u4e8e\u8fdb\u7a0b\u95f4\u7684\u540c\u6b65\u3002<\/li>\n<\/ul>\n<p><h3>17\u3001socket\u6a21\u5757<\/h3>\n<\/p>\n<p><p><code>socket<\/code>\u6a21\u5757\u63d0\u4f9b\u4e86\u7f51\u7edc\u901a\u4fe1\u7684\u652f\u6301\u3002\u5e38\u7528\u529f\u80fd\u5305\u62ec\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>\u521b\u5efa\u5957\u63a5\u5b57<\/strong>\uff1a<code>socket.socket()<\/code>\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u5957\u63a5\u5b57\u5bf9\u8c61\uff0c\u7528\u4e8e\u7f51\u7edc\u901a\u4fe1\u3002<\/li>\n<li><strong>\u7ed1\u5b9a\u5730\u5740<\/strong>\uff1a\u670d\u52a1\u5668\u7aef\u4f7f\u7528<code>bind()<\/code>\u65b9\u6cd5\u7ed1\u5b9a\u5730\u5740\uff0c\u5ba2\u6237\u7aef\u4f7f\u7528<code>connect()<\/code>\u65b9\u6cd5\u8fde\u63a5\u670d\u52a1\u5668\u3002<\/li>\n<li><strong>\u53d1\u9001\u548c\u63a5\u6536\u6570\u636e<\/strong>\uff1a\u4f7f\u7528<code>send()<\/code>\u548c<code>recv()<\/code>\u65b9\u6cd5\u53d1\u9001\u548c\u63a5\u6536\u6570\u636e\u3002<\/li>\n<\/ul>\n<p><h3>18\u3001hashlib\u6a21\u5757<\/h3>\n<\/p>\n<p><p><code>hashlib<\/code>\u6a21\u5757\u63d0\u4f9b\u4e86\u54c8\u5e0c\u7b97\u6cd5\u7684\u652f\u6301\u3002\u5e38\u7528\u529f\u80fd\u5305\u62ec\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>\u521b\u5efa\u54c8\u5e0c\u5bf9\u8c61<\/strong>\uff1a\u5982<code>hashlib.md5()<\/code>\u3001<code>hashlib.sha256()<\/code>\u7b49\u53ef\u4ee5\u521b\u5efa\u4e0d\u540c\u7b97\u6cd5\u7684\u54c8\u5e0c\u5bf9\u8c61\u3002<\/li>\n<li><strong>\u66f4\u65b0\u54c8\u5e0c\u5bf9\u8c61<\/strong>\uff1a\u4f7f\u7528<code>update()<\/code>\u65b9\u6cd5\u53ef\u4ee5\u66f4\u65b0\u54c8\u5e0c\u5bf9\u8c61\u7684\u6570\u636e\u3002<\/li>\n<li><strong>\u83b7\u53d6\u54c8\u5e0c\u503c<\/strong>\uff1a\u4f7f\u7528<code>hexdigest()<\/code>\u65b9\u6cd5\u53ef\u4ee5\u83b7\u53d6\u54c8\u5e0c\u503c\u7684\u5341\u516d\u8fdb\u5236\u8868\u793a\u3002<\/li>\n<\/ul>\n<p><h3>19\u3001xml\u6a21\u5757<\/h3>\n<\/p>\n<p><p><code>xml<\/code>\u6a21\u5757\u63d0\u4f9b\u4e86\u5904\u7406XML\u6587\u6863\u7684\u529f\u80fd\u3002\u5e38\u7528\u529f\u80fd\u5305\u62ec\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>\u89e3\u6790XML\u6587\u6863<\/strong>\uff1a<code>xml.etree.ElementTree<\/code>\u5b50\u6a21\u5757\u63d0\u4f9b\u4e86\u89e3\u6790XML\u6587\u6863\u7684\u529f\u80fd\uff0c\u53ef\u4ee5\u5c06XML\u6587\u6863\u89e3\u6790\u4e3a\u6811\u5f62\u7ed3\u6784\u3002<\/li>\n<li><strong>\u521b\u5efaXML\u6587\u6863<\/strong>\uff1a\u53ef\u4ee5\u4f7f\u7528<code>Element<\/code>\u7c7b\u521b\u5efaXML\u5143\u7d20\uff0c\u4f7f\u7528<code>SubElement<\/code>\u7c7b\u521b\u5efa\u5b50\u5143\u7d20\uff0c\u7136\u540e\u4f7f\u7528<code>ElementTree<\/code>\u7c7b\u751f\u6210XML\u6587\u6863\u3002<\/li>\n<\/ul>\n<p><h3>20\u3001configparser\u6a21\u5757<\/h3>\n<\/p>\n<p><p><code>configparser<\/code>\u6a21\u5757\u63d0\u4f9b\u4e86\u5904\u7406\u914d\u7f6e\u6587\u4ef6\u7684\u529f\u80fd\u3002\u5e38\u7528\u529f\u80fd\u5305\u62ec\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>\u8bfb\u53d6\u914d\u7f6e\u6587\u4ef6<\/strong>\uff1a<code>ConfigParser<\/code>\u7c7b\u53ef\u4ee5\u8bfb\u53d6\u914d\u7f6e\u6587\u4ef6\uff0c\u63d0\u4f9b<code>get()<\/code>\u3001<code>set()<\/code>\u65b9\u6cd5\u83b7\u53d6\u548c\u8bbe\u7f6e\u914d\u7f6e\u9879\u7684\u503c\u3002<\/li>\n<li><strong>\u5199\u5165\u914d\u7f6e\u6587\u4ef6<\/strong>\uff1a<code>write()<\/code>\u65b9\u6cd5\u53ef\u4ee5\u5c06\u914d\u7f6e\u5199\u5165\u6587\u4ef6\u3002<\/li>\n<\/ul>\n<p><p>\u603b\u7ed3<\/p>\n<\/p>\n<p><p>\u901a\u8fc7\u67e5\u770b\u5b98\u65b9\u6587\u6863\u3001\u4f7f\u7528help()\u51fd\u6570\u3001dir()\u51fd\u6570\u548c\u67e5\u770b\u6e90\u7801\uff0c\u4f60\u53ef\u4ee5\u5168\u9762\u4e86\u89e3Python\u5185\u7f6e\u6a21\u5757\u7684\u529f\u80fd\u3002\u6b64\u5916\uff0c\u4e86\u89e3\u5e38\u89c1\u5185\u7f6e\u6a21\u5757\u7684\u4e3b\u8981\u529f\u80fd\uff0c\u53ef\u4ee5\u5e2e\u52a9\u4f60\u5728\u7f16\u5199\u4ee3\u7801\u65f6\u5feb\u901f\u9009\u62e9\u5408\u9002\u7684\u6a21\u5757\uff0c\u63d0\u9ad8\u5f00\u53d1\u6548\u7387\u3002\u5e0c\u671b\u672c\u6587\u5bf9\u4f60\u4e86\u89e3Python\u5185\u7f6e\u6a21\u5757\u7684\u529f\u80fd\u6709\u6240\u5e2e\u52a9\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u67e5\u770bPython\u5185\u7f6e\u6a21\u5757\u7684\u6587\u6863\u548c\u529f\u80fd\u8bf4\u660e\uff1f<\/strong><br \/>Python\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u6587\u6863\u8d44\u6e90\uff0c\u7528\u6237\u53ef\u4ee5\u901a\u8fc7\u8bbf\u95ee\u5b98\u65b9\u6587\u6863\u7f51\u7ad9\uff08<a href=\"https:\/\/docs.python.org\/3\/library\/%EF%BC%89%E6%9D%A5%E6%9F%A5%E9%98%85%E5%86%85%E7%BD%AE%E6%A8%A1%E5%9D%97%E7%9A%84%E8%AF%A6%E7%BB%86%E5%8A%9F%E8%83%BD%E8%AF%B4%E6%98%8E%E3%80%82%E6%AF%8F%E4%B8%AA%E6%A8%A1%E5%9D%97%E9%83%BD%E6%9C%89%E7%8B%AC%E7%AB%8B%E7%9A%84%E9%A1%B5%E9%9D%A2%EF%BC%8C%E5%8C%85%E5%90%AB%E6%A8%A1%E5%9D%97%E7%9A%84%E4%BB%8B%E7%BB%8D%E3%80%81%E5%8A%9F%E8%83%BD%E3%80%81%E7%94%A8%E6%B3%95%E7%A4%BA%E4%BE%8B%E4%BB%A5%E5%8F%8A%E5%B8%B8%E7%94%A8%E6%96%B9%E6%B3%95%E7%9A%84%E8%AF%B4%E6%98%8E%E3%80%82%E6%AD%A4%E5%A4%96%EF%BC%8C%E4%BD%BF%E7%94%A8%60help()%60%E5%87%BD%E6%95%B0%E5%9C%A8Python%E8%A7%A3%E9%87%8A%E5%99%A8%E4%B8%AD%E4%B9%9F%E8%83%BD%E5%BF%AB%E9%80%9F%E8%8E%B7%E5%8F%96%E6%9F%90%E4%B8%AA%E6%A8%A1%E5%9D%97%E7%9A%84%E5%B8%AE%E5%8A%A9%E4%BF%A1%E6%81%AF%EF%BC%8C%E4%BE%8B%E5%A6%82%60help(math)%60%E5%B0%86%E6%8F%90%E4%BE%9B%E6%95%B0%E5%AD%A6%E6%A8%A1%E5%9D%97%E7%9A%84%E7%9B%B8%E5%85%B3%E4%BF%A1%E6%81%AF%E3%80%82\">https:\/\/docs.python.org\/3\/library\/\uff09\u6765\u67e5\u9605\u5185\u7f6e\u6a21\u5757\u7684\u8be6\u7ec6\u529f\u80fd\u8bf4\u660e\u3002\u6bcf\u4e2a\u6a21\u5757\u90fd\u6709\u72ec\u7acb\u7684\u9875\u9762\uff0c\u5305\u542b\u6a21\u5757\u7684\u4ecb\u7ecd\u3001\u529f\u80fd\u3001\u7528\u6cd5\u793a\u4f8b\u4ee5\u53ca\u5e38\u7528\u65b9\u6cd5\u7684\u8bf4\u660e\u3002\u6b64\u5916\uff0c\u4f7f\u7528`help()`\u51fd\u6570\u5728Python\u89e3\u91ca\u5668\u4e2d\u4e5f\u80fd\u5feb\u901f\u83b7\u53d6\u67d0\u4e2a\u6a21\u5757\u7684\u5e2e\u52a9\u4fe1\u606f\uff0c\u4f8b\u5982`help(math)`\u5c06\u63d0\u4f9b\u6570\u5b66\u6a21\u5757\u7684\u76f8\u5173\u4fe1\u606f\u3002<\/a><\/p>\n<p><strong>\u662f\u5426\u6709\u5de5\u5177\u53ef\u4ee5\u5e2e\u52a9\u6211\u6d4f\u89c8Python\u5185\u7f6e\u6a21\u5757\u7684\u529f\u80fd\uff1f<\/strong><br \/>\u6709\u591a\u4e2a\u5de5\u5177\u53ef\u4ee5\u5e2e\u52a9\u7528\u6237\u66f4\u597d\u5730\u7406\u89e3\u548c\u6d4f\u89c8Python\u5185\u7f6e\u6a21\u5757\u7684\u529f\u80fd\u3002\u5e38\u7528\u7684\u5305\u62ecJupyter Notebook\u548cIPython\uff0c\u5b83\u4eec\u5141\u8bb8\u7528\u6237\u4ee5\u4ea4\u4e92\u7684\u65b9\u5f0f\u8fd0\u884c\u4ee3\u7801\u5e76\u67e5\u770b\u6a21\u5757\u7684\u6587\u6863\u3002\u6b64\u5916\uff0c\u8fd8\u6709\u4e00\u4e9b\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\uff0c\u5982PyCharm\u548cVSCode\uff0c\u63d0\u4f9b\u4e86\u4ee3\u7801\u8865\u5168\u548c\u5373\u65f6\u6587\u6863\u67e5\u770b\u529f\u80fd\uff0c\u4f7f\u5f97\u4e86\u89e3\u5185\u7f6e\u6a21\u5757\u53d8\u5f97\u66f4\u52a0\u4fbf\u6377\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728\u4ee3\u7801\u4e2d\u5feb\u901f\u67e5\u627ePython\u5185\u7f6e\u6a21\u5757\u7684\u529f\u80fd\uff1f<\/strong><br \/>\u5728\u7f16\u5199\u4ee3\u7801\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528Python\u7684<code>dir()<\/code>\u51fd\u6570\u6765\u5217\u51fa\u4e00\u4e2a\u6a21\u5757\u7684\u6240\u6709\u5c5e\u6027\u548c\u65b9\u6cd5\u3002\u4f8b\u5982\uff0c\u8f93\u5165<code>dir(os)<\/code>\u53ef\u4ee5\u67e5\u770b\u64cd\u4f5c\u7cfb\u7edf\u6a21\u5757<code>os<\/code>\u4e2d\u7684\u6240\u6709\u53ef\u7528\u529f\u80fd\u3002\u6b64\u5916\uff0c\u5229\u7528<code>__doc__<\/code>\u5c5e\u6027\u53ef\u4ee5\u76f4\u63a5\u8bbf\u95ee\u6a21\u5757\u7684\u6587\u6863\u5b57\u7b26\u4e32\uff0c\u4f8b\u5982<code>print(os.__doc__)<\/code>\u5c06\u663e\u793a\u8be5\u6a21\u5757\u7684\u7b80\u8981\u4ecb\u7ecd\u3002\u8fd9\u4e9b\u65b9\u6cd5\u80fd\u5e2e\u52a9\u7528\u6237\u5feb\u901f\u83b7\u53d6\u6240\u9700\u7684\u529f\u80fd\u4fe1\u606f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u8981\u77e5\u9053Python\u5185\u7f6e\u6a21\u5757\u6709\u54ea\u4e9b\u529f\u80fd\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\uff1a\u67e5\u770b\u5b98\u65b9\u6587\u6863\u3001\u4f7f\u7528help()\u51fd\u6570\u3001dir()\u51fd\u6570\u3001\u67e5 [&hellip;]","protected":false},"author":3,"featured_media":1080005,"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\/1079995"}],"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=1079995"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1079995\/revisions"}],"predecessor-version":[{"id":1080007,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1079995\/revisions\/1080007"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1080005"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1079995"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1079995"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1079995"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}