{"id":92051,"date":"2026-08-09T05:08:36","date_gmt":"2026-08-08T21:08:36","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/92051.html"},"modified":"2026-08-09T05:08:36","modified_gmt":"2026-08-08T21:08:36","slug":"%e4%bc%81%e4%b8%9a%e7%ba%a7python%e8%87%aa%e5%8a%a8%e5%8c%96%e8%bf%90%e7%bb%b4%e5%ae%9e%e6%88%98%ef%bc%88%e4%b8%89%ef%bc%89%ef%bc%9a%e5%a4%9a%e6%9c%8d%e5%8a%a1%e5%99%a8%e5%b9%b6%e5%8f%91%e5%b7%a1","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/92051.html","title":{"rendered":"\u4f01\u4e1a\u7ea7Python\u81ea\u52a8\u5316\u8fd0\u7ef4\u5b9e\u6218\uff08\u4e09\uff09\uff1a\u591a\u670d\u52a1\u5668\u5e76\u53d1\u5de1\u68c0\u4e0e\u67b6\u6784\u5347\u7ea7"},"content":{"rendered":"<p>\u4e13\u680f\u7b80\u4ecb&#xff1a; \u672c\u4e13\u680f\u5c06\u4ece\u5355\u673a\u5de1\u68c0\u8d77\u6b65&#xff0c;\u9010\u6b65\u6f14\u8fdb\u5230\u591a\u673a\u6279\u91cf\u5de1\u68c0\u3001\u5f02\u5e38\u544a\u8b66\u63a8\u9001\u3001\u53ef\u89c6\u5316Dashboard&#xff0c;\u6700\u7ec8\u6784\u5efa\u4e00\u5957\u5b8c\u6574\u7684\u4f01\u4e1a\u7ea7\u81ea\u52a8\u5316\u8fd0\u7ef4\u5e73\u53f0\u3002\u6bcf\u4e00\u7bc7\u90fd\u662f\u751f\u4ea7\u73af\u5883\u5b9e\u6218\u6c89\u6dc0&#xff0c;\u62d2\u7edd\u62d2\u7eddHello World\u5f0f\u6559\u5b66\u3002<\/p>\n<h5>&#x1f4cc; \u672c\u7bc7\u5bfc\u8bfb<\/h5>\n<p>\u5982\u679c\u6cbf\u7528\u4e0a\u4e00\u7bc7\u4f01\u4e1a\u7ea7Python\u81ea\u52a8\u5316\u8fd0\u7ef4\u5b9e\u6218&#xff08;\u4e8c&#xff09;&#xff1a;\u5355\u673a\u5347\u7ea7\u5230\u591a\u673a\u5de1\u68c0\u7cfb\u7edf&#xff0c;\u6211\u4eec\u9700\u8981\u5728\u6bcf\u53f0\u670d\u52a1\u5668\u4e0a\u90fd\u6267\u884c\u4e00\u904d&#xff0c;\u8fdb\u884c\u4e09\u6b21ssh\u94fe\u63a5&#xff0c;\u6548\u7387\u6781\u4f4e\u3002\u672c\u7bc7\u6211\u4eec\u5c06\u8fce\u6765V2.1\u7248\u672c\u7684\u91cd\u5927\u5347\u7ea7&#xff0c;\u5c06\u5355\u673a\u811a\u672c\u6f14\u8fdb\u4e3a\u591a\u673a\u5e76\u53d1\u5de1\u68c0\u7cfb\u7edf\u3002\u6211\u4eec\u5c06\u5f15\u5165SSH\u5bc6\u94a5\u8ba4\u8bc1\u3001\u591a\u7ebf\u7a0b\u5e76\u53d1\u3001\u7ed3\u6784\u5316\u6570\u636e\u89e3\u6790\u4ee5\u53ca\u5b8c\u5584\u7684\u65e5\u5fd7\u7cfb\u7edf&#xff0c;\u6253\u9020\u771f\u6b63\u7b26\u5408\u4f01\u4e1a\u7ea7\u6807\u51c6\u7684\u81ea\u52a8\u5316\u8fd0\u7ef4\u5de5\u5177\u3002<\/p>\n<table>\n<tr>\u75db\u70b9\/\u95ee\u9898V2\u00a0\u7248\u672c\u73b0\u72b6V2.1 \u4f01\u4e1a\u7ea7\u8981\u6c42<\/tr>\n<tbody>\n<tr>\n<td>\u8ba4\u8bc1\u65b9\u5f0f<\/td>\n<td>\u5bc6\u7801\/\u8d26\u53f7\u660e\u6587\u6709\u98ce\u9669<\/td>\n<td>SSH Key \u514d\u5bc6\u8ba4\u8bc1<\/td>\n<\/tr>\n<tr>\n<td>\u6267\u884c\u6548\u7387<\/td>\n<td>\u5355\u53f0\u670d\u52a1\u5668\u9010\u4e2a\u68c0\u67e5<\/td>\n<td>\u591a\u7ebf\u7a0b\u5e76\u53d1\u6267\u884c<\/td>\n<\/tr>\n<tr>\n<td>\u5bb9\u9519\u80fd\u529b<\/td>\n<td>SSH\u5931\u8d25\u7a0b\u5e8f\u76f4\u63a5\u9000\u51fa<\/td>\n<td>\u5f02\u5e38\u5bb9\u9519&#xff0c;\u5355\u673a\u5931\u8d25\u4e0d\u5f71\u54cd\u6574\u4f53<\/td>\n<\/tr>\n<tr>\n<td>\u6570\u636e\u683c\u5f0f<\/td>\n<td>\u91c7\u96c6\u7ed3\u679c\u662f\u5b57\u7b26\u4e32<\/td>\n<td>\u7ed3\u6784\u5316\u6570\u636e&#xff08;JSON\/Dict&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u65e5\u5fd7\u7cfb\u7edf<\/td>\n<td>\u65e0\u65e5\u5fd7\u8bb0\u5f55<\/td>\n<td>\u6807\u51c6\u5316\u65e5\u5fd7\u7cfb\u7edf<\/td>\n<\/tr>\n<tr>\n<td>\u62a5\u544a\u8d28\u91cf<\/td>\n<td>\u7b80\u5355\u6587\u672c<\/td>\n<td>\u6807\u51c6\u5316HTML\u62a5\u544a<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>\u4e00\u3001 \u5b89\u5168\u57fa\u77f3&#xff1a;SSH Key \u514d\u5bc6\u8ba4\u8bc1<\/h4>\n<p>\u5728\u751f\u4ea7\u73af\u5883\u4e2d&#xff0c;\u660e\u6587\u7ba1\u7406\u670d\u52a1\u5668\u5bc6\u7801\u662f\u6781\u5927\u7684\u5b89\u5168\u9690\u60a3\u3002\u4f01\u4e1a\u7ea7\u8fd0\u7ef4\u7684\u6807\u51c6\u505a\u6cd5\u662f\u4f7f\u7528\u00a0SSH Key&#xff08;\u516c\u94a5\/\u79c1\u94a5&#xff09;\u00a0\u8fdb\u884c\u8ba4\u8bc1\u3002<\/p>\n<h5>1.1 \u751f\u6210 SSH \u79d8\u94a5<\/h5>\n<p>\u5728\u6211\u4eec\u7684\u5de1\u68c0\u670d\u52a1\u5668&#xff08;\u63a7\u5236\u673a&#xff09;\u4e0a\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4&#xff0c;\u4e00\u8def\u56de\u8f66\u5373\u53ef\u751f\u6210\u5bc6\u94a5\u5bf9&#xff1a;<\/p>\n<p>\u4f5c\u8005&#xff1a;\u996d\u8981\u52a0\u52a0\u52a0<br \/>\n\u5982\u9700\u4ee3\u7801\u538b\u7f29\u5305\u8bf7\u5173\u6ce8\u4f5c\u8005&#xff0c;\u79c1\u4fe1\u83b7\u53d6<br \/>\nssh-keygen -t rsa -b 4096 <\/p>\n<p>\u6267\u884c\u540e&#xff0c;~\/.ssh\/\u00a0\u76ee\u5f55\u4e0b\u4f1a\u751f\u6210\u00a0id_rsa&#xff08;\u79c1\u94a5&#xff09;\u548c\u00a0id_rsa.pub&#xff08;\u516c\u94a5&#xff09;\u3002<\/p>\n<h5>1.2 \u5206\u53d1\u516c\u94a5<\/h5>\n<p>\u5c06\u516c\u94a5\u590d\u5236\u5230\u76ee\u6807\u670d\u52a1\u5668\u4e0a&#xff0c;\u5b9e\u73b0\u514d\u5bc6\u767b\u5f55&#xff1a;<\/p>\n<p>ssh-copy-id root&#064;10.207.132.221 <\/p>\n<h5>1.3 \u914d\u7f6e\u7ba1\u7406<\/h5>\n<p>\u4fee\u6539\u00a0config\/server.yaml&#xff0c;\u5c06\u8ba4\u8bc1\u65b9\u5f0f\u4ece\u5bc6\u7801\u6539\u4e3a\u5bc6\u94a5\u6587\u4ef6\u8def\u5f84&#xff1a;<\/p>\n<p>servers:<br \/>\n  &#8211; name: master<br \/>\n    host: 10.207.132.221<br \/>\n    username: root<br \/>\n    key_file: C:\\\\Users\\\\Administrator\\\\.ssh\\\\id_rsa <\/p>\n<h5>1.4 \u5347\u7ea7 SSH \u6a21\u5757<\/h5>\n<p>\u4fee\u6539\u00a0ssh\/client.py&#xff0c;\u4f7f\u7528\u00a0paramiko\u00a0\u52a0\u8f7d\u79c1\u94a5\u8fdb\u884c\u8fde\u63a5\u3002<\/p>\n<p>import paramiko<\/p>\n<p>def ssh_execute(server, command):<br \/>\n    client &#061; paramiko.SSHClient()<br \/>\n    client.set_missing_host_key_policy(paramiko.AutoAddPolicy())<\/p>\n<p>    # \u52a0\u8f7d\u79c1\u94a5<br \/>\n    private_key &#061; paramiko.RSAKey.from_private_key_file(server[&#034;key_file&#034;])<\/p>\n<p>    client.connect(<br \/>\n        hostname&#061;server[&#034;host&#034;],<br \/>\n        username&#061;server[&#034;username&#034;],<br \/>\n        pkey&#061;private_key,<br \/>\n        timeout&#061;5<br \/>\n    )<\/p>\n<p>    stdin, stdout, stderr &#061; client.exec_command(command)<br \/>\n    result &#061; stdout.read().decode()<br \/>\n    client.close()<br \/>\n    return result <\/p>\n<hr \/>\n<h4 style=\"background-color:transparent\">\u4e8c\u3001 \u5065\u58ee\u6027\u5347\u7ea7&#xff1a;\u589e\u52a0 SSH \u5f02\u5e38\u5904\u7406<\/h4>\n<p>\u5728V1\u7248\u672c\u4e2d&#xff0c;\u5982\u679c\u67d0\u53f0\u670d\u52a1\u5668IP\u9519\u8bef\u6216\u5b95\u673a&#xff0c;\u7a0b\u5e8f\u4f1a\u76f4\u63a5\u5d29\u6e83\u9000\u51fa\u3002\u5728\u4f01\u4e1a\u73af\u5883\u4e2d&#xff0c;\u5355\u673a\u6545\u969c\u7edd\u4e0d\u80fd\u5f71\u54cd\u6574\u4f53\u5de1\u68c0\u4efb\u52a1\u7684\u6267\u884c\u3002<\/p>\n<p>\u6211\u4eec\u9700\u8981\u5bf9\u00a0ssh_execute\u00a0\u51fd\u6570\u8fdb\u884c\u201c\u9632\u5fa1\u6027\u7f16\u7a0b\u201d\u6539\u9020&#xff0c;\u6355\u83b7\u6240\u6709\u5f02\u5e38\u5e76\u8fd4\u56de\u7ed3\u6784\u5316\u7ed3\u679c&#xff1a;<\/p>\n<p>import paramiko<\/p>\n<p>def ssh_execute(server, command):<br \/>\n    try:<br \/>\n        client &#061; paramiko.SSHClient()<br \/>\n        client.set_missing_host_key_policy(paramiko.AutoAddPolicy())<br \/>\n        key &#061; paramiko.RSAKey.from_private_key_file(server[&#034;key_file&#034;])<\/p>\n<p>        client.connect(<br \/>\n            hostname&#061;server[&#034;host&#034;],<br \/>\n            username&#061;server[&#034;username&#034;],<br \/>\n            pkey&#061;key,<br \/>\n            timeout&#061;5<br \/>\n        )<\/p>\n<p>        stdin, stdout, stderr &#061; client.exec_command(command)<br \/>\n        result &#061; stdout.read().decode()<br \/>\n        client.close()<\/p>\n<p>        # \u6210\u529f\u8fd4\u56de success \u72b6\u6001<br \/>\n        return {<br \/>\n            &#034;status&#034;: &#034;success&#034;,<br \/>\n            &#034;data&#034;: result<br \/>\n        }<br \/>\n    except Exception as e:<br \/>\n        # \u5931\u8d25\u8fd4\u56de failed \u72b6\u6001\u53ca\u9519\u8bef\u4fe1\u606f&#xff0c;\u7a0b\u5e8f\u4e0d\u5d29\u6e83<br \/>\n        return {<br \/>\n            &#034;status&#034;: &#034;failed&#034;,<br \/>\n            &#034;error&#034;: str(e)<br \/>\n        } <\/p>\n<p>&#x1f4a1; \u6838\u5fc3\u77e5\u8bc6\u70b9&#xff1a;Paramiko \u5e38\u7528\u529f\u80fd<\/p>\n<table>\n<tr>\u529f\u80fd\u6838\u5fc3\u7c7b\u6838\u5fc3\u51fd\u6570\/\u65b9\u6cd5\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>SSH\u767b\u5f55<\/td>\n<td>SSHClient<\/td>\n<td>connect()<\/td>\n<td>\u5efa\u7acb\u8fde\u63a5&#xff0c;\u4f20\u5165IP\u3001\u7aef\u53e3\u3001\u7528\u6237\u540d\u3001\u5bc6\u94a5\u7b49\u3002<\/td>\n<\/tr>\n<tr>\n<td>\u6267\u884c\u547d\u4ee4<\/td>\n<td>SSHClient<\/td>\n<td>exec_command()<\/td>\n<td>\u6267\u884c\u547d\u4ee4&#xff0c;\u8fd4\u56de\u00a0stdin,\u00a0stdout,\u00a0stderr\u00a0\u4e09\u4e2a\u901a\u9053\u3002<\/td>\n<\/tr>\n<tr>\n<td>\u6587\u4ef6\u4e0a\u4f20<\/td>\n<td>SFTPClient<\/td>\n<td>put()<\/td>\n<td>\u4e0a\u4f20\u6587\u4ef6\u00a0(\u672c\u5730\u8def\u5f84, \u8fdc\u7a0b\u8def\u5f84)\u3002<\/td>\n<\/tr>\n<tr>\n<td>\u6587\u4ef6\u4e0b\u8f7d<\/td>\n<td>SFTPClient<\/td>\n<td>get()<\/td>\n<td>\u4e0b\u8f7d\u6587\u4ef6\u00a0(\u8fdc\u7a0b\u8def\u5f84, \u672c\u5730\u8def\u5f84)\u3002<\/td>\n<\/tr>\n<tr>\n<td>\u5bc6\u94a5\u8ba4\u8bc1<\/td>\n<td>RSAKey<\/td>\n<td>from_private_key_file()<\/td>\n<td>\u52a0\u8f7d\u79c1\u94a5\u6587\u4ef6&#xff0c;\u914d\u5408\u00a0connect(pkey&#061;)\u00a0\u4f7f\u7528\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h4>\u4e09\u3001 \u6027\u80fd\u98de\u8dc3&#xff1a;\u91cd\u6784\u6570\u636e\u91c7\u96c6\u4e0e\u591a\u7ebf\u7a0b\u5e76\u53d1<\/h4>\n<h5>3.1 \u91c7\u96c6\u7b56\u7565\u91cd\u6784<\/h5>\n<p>\u4e4b\u524d\u7684\u505a\u6cd5\u662f\u201c\u91c7\u96c6\u4e00\u4e2a\u6307\u6807\u5efa\u7acb\u4e00\u6b21SSH\u8fde\u63a5\u201d&#xff0c;\u8fd9\u5728\u591a\u673a\u5de1\u68c0\u4e2d\u662f\u81f4\u547d\u7684\u6027\u80fd\u74f6\u9888\u3002 \u4f18\u5316\u65b9\u6848&#xff1a;\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5165\u53e3\u00a0collectors\/server.py&#xff0c;\u4e00\u6b21SSH\u8fde\u63a5&#xff0c;\u6279\u91cf\u6267\u884c\u6240\u6709\u547d\u4ee4&#xff0c;\u7136\u540e\u5728\u672c\u5730\u8fdb\u884c\u89e3\u6790\u3002<\/p>\n<p># collectors\/server.py<br \/>\nfrom ssh.client import ssh_execute<br \/>\nfrom parser.cpu import parse_cpu<br \/>\nfrom parser.memory import parse_memory<br \/>\nfrom parser.disk import parse_disk<\/p>\n<p>def inspect_server(server):<br \/>\n    # \u4e00\u6b21\u6027\u6267\u884c\u591a\u4e2a\u547d\u4ee4<br \/>\n    command &#061; &#034;&#034;&#034;<br \/>\n    echo CPU<br \/>\n    top -bn1 | grep Cpu<br \/>\n    echo MEMORY<br \/>\n    free -m<br \/>\n    echo DISK<br \/>\n    df -h \/<br \/>\n    &#034;&#034;&#034;<\/p>\n<p>    result &#061; ssh_execute(server, command)<\/p>\n<p>    if result[&#034;status&#034;] !&#061; &#034;success&#034;:<br \/>\n        return {<br \/>\n            &#034;name&#034;: server[&#034;name&#034;],<br \/>\n            &#034;status&#034;: &#034;failed&#034;,<br \/>\n            &#034;error&#034;: result[&#034;data&#034;]<br \/>\n        }<\/p>\n<p>    raw_data &#061; result[&#034;data&#034;]<\/p>\n<p>    # \u672c\u5730\u89e3\u6790\u6570\u636e<br \/>\n    return {<br \/>\n        &#034;name&#034;: server[&#034;name&#034;],<br \/>\n        &#034;cpu&#034;: parse_cpu(raw_data),<br \/>\n        &#034;memory&#034;: parse_memory(raw_data),<br \/>\n        &#034;disk&#034;: parse_disk(raw_data),<br \/>\n        &#034;status&#034;: &#034;success&#034;<br \/>\n    } <\/p>\n<h5>3.2 \u6570\u636e\u7ed3\u6784\u5316&#xff1a;Parser \u6a21\u5757<\/h5>\n<p>SSH \u8fd4\u56de\u7684\u662f\u5b57\u7b26\u4e32&#xff0c;\u7a0b\u5e8f\u65e0\u6cd5\u76f4\u63a5\u5224\u65ad\u5927\u5c0f\u3002\u6211\u4eec\u9700\u8981\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f&#xff08;re\u00a0\u6a21\u5757&#xff09;\u5c06\u5176\u8f6c\u6362\u4e3a\u6570\u5b57\u3002<\/p>\n<p>\u521b\u5efa\u00a0parser\/\u00a0\u76ee\u5f55&#xff1a;<\/p>\n<p>parser\/cpu.py<\/p>\n<p>import re<br \/>\ndef parse_cpu(data):<br \/>\n    result &#061; re.search(r&#039;(\\\\d&#043;\\\\.\\\\d&#043;)\\\\s*id&#039;, data)<br \/>\n    if result:<br \/>\n        idle &#061; float(result.group(1))<br \/>\n        return round(100 &#8211; idle, 2)<br \/>\n    return 0 <\/p>\n<p>parser\/disk.py<\/p>\n<p>import re<br \/>\ndef parse_disk(data):<br \/>\n    result &#061; re.search(r&#039;(\\\\d&#043;)%\\\\s&#043;\/&#039;, data)<br \/>\n    if result:<br \/>\n        return float(result.group(1))<br \/>\n    return 0 <\/p>\n<p>parser\/memory.py<\/p>\n<p>import re<br \/>\ndef parse_memory(data):<br \/>\n    result &#061; re.search(r&#039;Mem:\\\\s&#043;(\\\\d&#043;)\\\\s&#043;(\\\\d&#043;)&#039;, data)<br \/>\n    if result:<br \/>\n        total &#061; float(result.group(1))<br \/>\n        used &#061; float(result.group(2))<br \/>\n        if total &gt; 0:<br \/>\n            return round(used \/ total * 100, 2)<br \/>\n    return 0 <\/p>\n<p>&#x1f4a1; \u6838\u5fc3\u77e5\u8bc6\u70b9&#xff1a;Python \u6b63\u5219 re \u6a21\u5757<\/p>\n<table>\n<tr>\u6838\u5fc3\u529f\u80fd\u5bf9\u5e94\u51fd\u6570\/\u65b9\u6cd5\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>\u5168\u5c40\u641c\u7d22&#xff08;\u9996\u4e2a&#xff09;<\/td>\n<td>re.search()<\/td>\n<td>\u626b\u63cf\u6574\u4e2a\u5b57\u7b26\u4e32&#xff0c;\u8fd4\u56de\u7b2c\u4e00\u4e2a\u5339\u914d\u7ed3\u679c&#xff08;\u6700\u5e38\u7528&#xff09;\u3002<\/td>\n<\/tr>\n<tr>\n<td>\u5168\u5c40\u641c\u7d22&#xff08;\u5168\u90e8&#xff09;<\/td>\n<td>re.findall()<\/td>\n<td>\u8fd4\u56de\u5217\u8868&#xff0c;\u5305\u542b\u6240\u6709\u5339\u914d\u7ed3\u679c\u3002<\/td>\n<\/tr>\n<tr>\n<td>\u4ece\u5934\u5339\u914d<\/td>\n<td>re.match()<\/td>\n<td>\u4ec5\u4ece\u5b57\u7b26\u4e32\u5f00\u5934\u5339\u914d&#xff0c;\u4e0d\u5e38\u7528\u3002<\/td>\n<\/tr>\n<tr>\n<td>\u5b57\u7b26\u4e32\u66ff\u6362<\/td>\n<td>re.sub()<\/td>\n<td>\u66ff\u6362\u5339\u914d\u7684\u5b57\u7b26\u4e32\u3002<\/td>\n<\/tr>\n<tr>\n<td>\u7f16\u8bd1\u5bf9\u8c61<\/td>\n<td>re.compile()<\/td>\n<td>\u9884\u7f16\u8bd1\u6b63\u5219&#xff0c;\u63d0\u9ad8\u91cd\u590d\u4f7f\u7528\u65f6\u7684\u6027\u80fd\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h5 style=\"background-color:transparent\">3.3 \u591a\u7ebf\u7a0b\u5e76\u53d1\u6267\u884c<\/h5>\n<p>\u5f53\u9762\u5bf9 100 \u53f0\u670d\u52a1\u5668\u65f6&#xff0c;\u4e32\u884c\u6267\u884c\u53ef\u80fd\u9700\u8981 500 \u79d2&#xff08;\u5047\u8bbe\u6bcf\u53f05\u79d2&#xff09;&#xff0c;\u8fd9\u662f\u4e0d\u53ef\u63a5\u53d7\u7684\u3002\u6211\u4eec\u4f7f\u7528\u00a0concurrent.futures\u00a0\u5b9e\u73b0\u591a\u7ebf\u7a0b\u5e76\u53d1\u3002<\/p>\n<p>\u521b\u5efa\u00a0core\/task.py&#xff1a;<\/p>\n<p>from concurrent.futures import ThreadPoolExecutor, as_completed<\/p>\n<p>def run_parallel(tasks, max_workers&#061;10):<br \/>\n    &#034;&#034;&#034;<br \/>\n    tasks: [(\u51fd\u6570, \u53c2\u6570), &#8230;]<br \/>\n    max_workers: \u6700\u5927\u7ebf\u7a0b\u6570<br \/>\n    &#034;&#034;&#034;<br \/>\n    results &#061; []<br \/>\n    with ThreadPoolExecutor(max_workers&#061;max_workers) as executor:<br \/>\n        future_list &#061; []<br \/>\n        for func, args in tasks:<br \/>\n            future &#061; executor.submit(func, args)<br \/>\n            future_list.append(future)<\/p>\n<p>        for future in as_completed(future_list):<br \/>\n            try:<br \/>\n                result &#061; future.result()<br \/>\n                results.append(result)<br \/>\n            except Exception as e:<br \/>\n                results.append({&#034;status&#034;: &#034;failed&#034;, &#034;error&#034;: str(e)})<br \/>\n    return results <\/p>\n<p>&#x1f4a1; \u6838\u5fc3\u77e5\u8bc6\u70b9&#xff1a;ThreadPoolExecutor\u00a0<\/p>\n<table>\n<tr>\u6838\u5fc3\u529f\u80fd\u5bf9\u5e94\u51fd\u6570\/\u65b9\u6cd5\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>\u521b\u5efa\u7ebf\u7a0b\u6c60<\/td>\n<td>ThreadPoolExecutor(max_workers&#061;N)<\/td>\n<td>\u521b\u5efa\u5305\u542b N \u4e2a\u7ebf\u7a0b\u7684\u6c60\u5b50\u3002<\/td>\n<\/tr>\n<tr>\n<td>\u63d0\u4ea4\u4efb\u52a1<\/td>\n<td>submit(fn, *args)<\/td>\n<td>\u63d0\u4ea4\u4efb\u52a1&#xff0c;\u7acb\u5373\u8fd4\u56de\u00a0Future\u00a0\u5bf9\u8c61\u3002<\/td>\n<\/tr>\n<tr>\n<td>\u5173\u95ed\u7ebf\u7a0b\u6c60<\/td>\n<td>shutdown(wait&#061;True)<\/td>\n<td>\u7b49\u5f85\u4efb\u52a1\u5b8c\u6210\u5e76\u5173\u95ed&#xff08;\u901a\u5e38\u914d\u5408\u00a0with\u00a0\u4f7f\u7528&#xff09;\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5173\u4e8e Future \u5bf9\u8c61&#xff1a;<\/p>\n<ul>\n<li>future.result(): \u963b\u585e\u7b49\u5f85\u4efb\u52a1\u5b8c\u6210\u5e76\u83b7\u53d6\u8fd4\u56de\u503c\u3002<\/li>\n<li>future.done(): \u5224\u65ad\u4efb\u52a1\u662f\u5426\u5b8c\u6210\u3002<\/li>\n<li>future.exception(): \u83b7\u53d6\u4efb\u52a1\u6267\u884c\u65f6\u7684\u5f02\u5e38\u3002<\/li>\n<\/ul>\n<hr \/>\n<h4 style=\"background-color:transparent\">\u56db\u3001 \u53ef\u89c2\u6d4b\u6027&#xff1a;\u589e\u52a0\u65e5\u5fd7\u7cfb\u7edf<\/h4>\n<p>\u4f01\u4e1a\u7ea7\u9879\u76ee\u5fc5\u987b\u6709\u65e5\u5fd7\u3002\u6211\u4eec\u5c06\u4f7f\u7528 Python \u5185\u7f6e\u7684\u00a0logging\u00a0\u6a21\u5757\u8bb0\u5f55\u5de1\u68c0\u8fc7\u7a0b\u3002<\/p>\n<p>\u5728\u00a0main.py\u00a0\u4e2d\u914d\u7f6e\u65e5\u5fd7&#xff1a;<\/p>\n<p>import logging<\/p>\n<p>logging.basicConfig(<br \/>\n    filename&#061;&#034;logs\/app.log&#034;,<br \/>\n    level&#061;logging.INFO,<br \/>\n    format&#061;&#034;%(asctime)s %(levelname)s %(message)s&#034;<br \/>\n)<\/p>\n<p># \u4f7f\u7528\u793a\u4f8b<br \/>\nlogging.info(&#034;\u5f00\u59cb\u5de1\u68c0 web01&#034;)<br \/>\nlogging.error(&#034;web01 \u8fde\u63a5\u5931\u8d25&#034;) <\/p>\n<p>\u65e5\u5fd7\u8f93\u51fa\u793a\u4f8b&#xff1a; 2026-07-29 15:00 INFO \u5f00\u59cb\u5de1\u68c0web01 2026-07-29 15:01 ERROR web02 timeout<\/p>\n<hr \/>\n<h4 style=\"background-color:transparent\">\u4e94\u3001 \u6700\u7ec8\u6574\u5408&#xff1a;Main \u5165\u53e3\u4e0e\u62a5\u544a\u8c03\u6574<\/h4>\n<p>\u6700\u540e&#xff0c;\u6211\u4eec\u5c06\u6240\u6709\u6a21\u5757\u4e32\u8054\u8d77\u6765\u3002\u540c\u65f6&#xff0c;\u8c03\u6574\u00a0analyzer\/check.py\u00a0\u4ee5\u9002\u5e94\u65b0\u7684\u6570\u636e\u7ed3\u6784&#xff08;\u5305\u542b\u00a0name,\u00a0status\u00a0\u7b49\u5b57\u6bb5&#xff09;\u3002<\/p>\n<p>analyzer\/check.py<\/p>\n<p>CPU_THRESHOLD &#061; 80<br \/>\nMEMORY_THRESHOLD &#061; 80<br \/>\nDISK_THRESHOLD &#061; 90<\/p>\n<p>def check(data):<br \/>\n    alarms &#061; []<br \/>\n    # \u5148\u5224\u65ad\u91c7\u96c6\u662f\u5426\u6210\u529f<br \/>\n    if data.get(&#034;status&#034;) !&#061; &#034;success&#034;:<br \/>\n        alarms.append(&#034;\u670d\u52a1\u5668\u6570\u636e\u91c7\u96c6\u5931\u8d25&#034;)<br \/>\n        return alarms<\/p>\n<p>    # \u6307\u6807\u68c0\u67e5<br \/>\n    if data.get(&#034;cpu&#034;, 0) &gt; CPU_THRESHOLD:<br \/>\n        alarms.append(&#034;CPU\u4f7f\u7528\u7387\u8fc7\u9ad8&#034;)<br \/>\n    if data.get(&#034;memory&#034;, 0) &gt; MEMORY_THRESHOLD:<br \/>\n        alarms.append(&#034;\u5185\u5b58\u4f7f\u7528\u7387\u8fc7\u9ad8&#034;)<br \/>\n    if data.get(&#034;disk&#034;, 0) &gt; DISK_THRESHOLD:<br \/>\n        alarms.append(&#034;\u78c1\u76d8\u7a7a\u95f4\u4e0d\u8db3&#034;)<\/p>\n<p>    return alarms <\/p>\n<p>main.py<\/p>\n<p>import os<br \/>\nimport sys<br \/>\nimport logging<br \/>\nfrom config.ssh_config import load_servers<br \/>\nfrom report.report import create_report<br \/>\nfrom core.task import run_parallel<br \/>\nfrom analyzer.check import check<br \/>\nfrom collectors.server import inspect_server<\/p>\n<p>def main():<br \/>\n    logging.basicConfig(<br \/>\n        filename&#061;&#034;logs\/app.log&#034;,<br \/>\n        level&#061;logging.INFO,<br \/>\n        format&#061;&#034;%(asctime)s %(levelname)s %(message)s&#034;<br \/>\n    )<\/p>\n<p>    servers &#061; load_servers()<br \/>\n    tasks &#061; []<\/p>\n<p>    # \u6784\u5efa\u4efb\u52a1\u5217\u8868<br \/>\n    for server in servers:<br \/>\n        tasks.append((inspect_server, server))<\/p>\n<p>    # \u5e76\u53d1\u6267\u884c<br \/>\n    results &#061; run_parallel(tasks)<\/p>\n<p>    # \u5904\u7406\u7ed3\u679c<br \/>\n    for data in results:<br \/>\n        alarms &#061; check(data)<br \/>\n        data[&#034;alarms&#034;] &#061; alarms<\/p>\n<p>    # \u751f\u6210\u62a5\u544a<br \/>\n    create_report(results)<\/p>\n<p>if __name__ &#061;&#061; &#034;__main__&#034;:<br \/>\n    main() <\/p>\n<hr \/>\n<h4>\u516d.\u672c\u7bc7\u603b\u7ed3\u4e0e\u4e0b\u7bc7\u9884\u544a<\/h4>\n<h5>\u2705 \u672c\u7bc7\u6536\u83b7<\/h5>\n<p>\u81f3\u6b64&#xff0c;\u6211\u4eec\u7684\u5de1\u68c0\u7cfb\u7edf\u5b8c\u6210\u4e86\u4ece\u201c\u5355\u673a\u811a\u672c\u201d\u5230\u201c\u4f01\u4e1a\u7ea7\u5de5\u5177\u201d\u7684\u534e\u4e3d\u8f6c\u8eab&#xff1a;<\/p>\n<li>\u5b89\u5168\u6027&#xff1a;\u5f15\u5165 SSH Key&#xff0c;\u544a\u522b\u660e\u6587\u5bc6\u7801\u3002<\/li>\n<li>\u5065\u58ee\u6027&#xff1a;\u5b8c\u5584\u7684\u5f02\u5e38\u6355\u83b7&#xff0c;\u5355\u70b9\u6545\u969c\u4e0d\u5f71\u54cd\u5168\u5c40\u3002<\/li>\n<li>\u9ad8\u6027\u80fd&#xff1a;\u591a\u7ebf\u7a0b\u5e76\u53d1 &#043; \u5355\u6b21\u8fde\u63a5\u6279\u91cf\u6267\u884c&#xff0c;\u6548\u7387\u63d0\u5347\u6570\u500d\u3002<\/li>\n<li>\u6807\u51c6\u5316&#xff1a;\u7ed3\u6784\u5316\u6570\u636e\u89e3\u6790 &#043; \u6807\u51c6\u65e5\u5fd7\u7cfb\u7edf\u3002<\/li>\n<p>&#x1f680; \u4e0b\u7bc7\u9884\u544a&#xff1a;\u6570\u636e\u5e93\u4e0eWeb\u76d1\u63a7\u5e73\u53f0\u6539\u9020 \u7cfb\u7edf\u5df2\u7ecf\u8dd1\u8d77\u6765\u4e86&#xff0c;\u4f46\u62a5\u544a\u8fd8\u662f\u592a\u7b80\u964b&#xff1f;\u544a\u8b66\u53ea\u80fd\u770b\u65e5\u5fd7&#xff1f; \u5728\u4e0b\u4e00\u7bc7\u6587\u7ae0\u4e2d&#xff0c;\u6211\u4eec\u5c06\u8fdb\u884c\u6570\u636e\u6301\u4e45\u5316\u5230\u6570\u636e\u5e93&#xff0c;\u5236\u4f5c\u7cbe\u7f8e\u7684 HTML \u53ef\u89c6\u5316\u62a5\u544a&#xff0c;\u5e76\u63a5\u5165\u00a0\u4f01\u4e1a\u5fae\u4fe1\/\u9489\u9489\u673a\u5668\u4eba&#xff0c;\u5b9e\u73b0\u771f\u6b63\u7684\u5b9e\u65f6\u544a\u8b66\u63a8\u9001&#xff01;<\/p>\n<p>&#x1f31f; \u521b\u4f5c\u4e0d\u6613&#xff0c;\u5982\u679c\u8fd9\u7bc7\u6587\u7ae0\u5bf9\u4f60\u6709\u5e2e\u52a9&#xff0c;\u6b22\u8fce\u70b9\u8d5e &#x1f44d;\u3001\u6536\u85cf \u2b50\u3001\u5173\u6ce8 &#x1f514; \u4e09\u8fde\u652f\u6301&#xff01;\u4f60\u7684\u652f\u6301\u662f\u6211\u6301\u7eed\u66f4\u65b0\u7684\u6700\u5927\u52a8\u529b\u3002\u6709\u4efb\u4f55\u95ee\u9898\u6216\u5efa\u8bae&#xff0c;\u6b22\u8fce\u5728\u8bc4\u8bba\u533a\u7559\u8a00\u4ea4\u6d41&#xff0c;\u6211\u4f1a\u4e00\u4e00\u56de\u590d&#xff01;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e13\u680f\u7b80\u4ecb&#xff1a; \u672c\u4e13\u680f\u5c06\u4ece\u5355\u673a\u5de1\u68c0\u8d77\u6b65&#xff0c;\u9010\u6b65\u6f14\u8fdb\u5230\u591a\u673a\u6279\u91cf\u5de1\u68c0\u3001\u5f02\u5e38\u544a\u8b66\u63a8\u9001\u3001\u53ef\u89c6\u5316Dashboard&#xff0c;\u6700\u7ec8\u6784\u5efa\u4e00\u5957\u5b8c\u6574\u7684\u4f01\u4e1a\u7ea7\u81ea\u52a8\u5316\u8fd0\u7ef4\u5e73\u53f0\u3002\u6bcf\u4e00\u7bc7\u90fd\u662f\u751f\u4ea7\u73af\u5883\u5b9e\u6218\u6c89\u6dc0&#xff0c;\u62d2\u7edd\u62d2\u7eddHello World\u5f0f\u6559\u5b66\u3002<br \/>\n&#x1f4cc; \u672c\u7bc7\u5bfc\u8bfb<br \/>\n\u5982\u679c\u6cbf\u7528\u4e0a\u4e00\u7bc7\u4f01\u4e1a\u7ea7Python\u81ea\u52a8\u5316\u8fd0\u7ef4\u5b9e\u6218&#xff08;\u4e8c&#xff09;&#xff1a;\u5355\u673a\u5347\u7ea7\u5230\u591a\u673a\u5de1\u68c0\u7cfb\u7edf&#xff0c;\u6211\u4eec\u9700\u8981\u5728\u6bcf\u53f0\u670d\u52a1\u5668\u4e0a\u90fd\u6267\u884c\u4e00\u904d&#xff0c;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[81,188,395,44,250],"topic":[],"class_list":["post-92051","post","type-post","status-publish","format-standard","hentry","category-server","tag-python","tag-188","tag-395","tag-44","tag-250"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u4f01\u4e1a\u7ea7Python\u81ea\u52a8\u5316\u8fd0\u7ef4\u5b9e\u6218\uff08\u4e09\uff09\uff1a\u591a\u670d\u52a1\u5668\u5e76\u53d1\u5de1\u68c0\u4e0e\u67b6\u6784\u5347\u7ea7 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/92051.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u4f01\u4e1a\u7ea7Python\u81ea\u52a8\u5316\u8fd0\u7ef4\u5b9e\u6218\uff08\u4e09\uff09\uff1a\u591a\u670d\u52a1\u5668\u5e76\u53d1\u5de1\u68c0\u4e0e\u67b6\u6784\u5347\u7ea7 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u4e13\u680f\u7b80\u4ecb&#xff1a; \u672c\u4e13\u680f\u5c06\u4ece\u5355\u673a\u5de1\u68c0\u8d77\u6b65&#xff0c;\u9010\u6b65\u6f14\u8fdb\u5230\u591a\u673a\u6279\u91cf\u5de1\u68c0\u3001\u5f02\u5e38\u544a\u8b66\u63a8\u9001\u3001\u53ef\u89c6\u5316Dashboard&#xff0c;\u6700\u7ec8\u6784\u5efa\u4e00\u5957\u5b8c\u6574\u7684\u4f01\u4e1a\u7ea7\u81ea\u52a8\u5316\u8fd0\u7ef4\u5e73\u53f0\u3002\u6bcf\u4e00\u7bc7\u90fd\u662f\u751f\u4ea7\u73af\u5883\u5b9e\u6218\u6c89\u6dc0&#xff0c;\u62d2\u7edd\u62d2\u7eddHello World\u5f0f\u6559\u5b66\u3002 &#x1f4cc; \u672c\u7bc7\u5bfc\u8bfb \u5982\u679c\u6cbf\u7528\u4e0a\u4e00\u7bc7\u4f01\u4e1a\u7ea7Python\u81ea\u52a8\u5316\u8fd0\u7ef4\u5b9e\u6218&#xff08;\u4e8c&#xff09;&#xff1a;\u5355\u673a\u5347\u7ea7\u5230\u591a\u673a\u5de1\u68c0\u7cfb\u7edf&#xff0c;\u6211\u4eec\u9700\u8981\u5728\u6bcf\u53f0\u670d\u52a1\u5668\u4e0a\u90fd\u6267\u884c\u4e00\u904d&#xff0c;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/92051.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-08-08T21:08:36+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/92051.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/92051.html\",\"name\":\"\u4f01\u4e1a\u7ea7Python\u81ea\u52a8\u5316\u8fd0\u7ef4\u5b9e\u6218\uff08\u4e09\uff09\uff1a\u591a\u670d\u52a1\u5668\u5e76\u53d1\u5de1\u68c0\u4e0e\u67b6\u6784\u5347\u7ea7 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-08-08T21:08:36+00:00\",\"dateModified\":\"2026-08-08T21:08:36+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/92051.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/92051.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/92051.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u4f01\u4e1a\u7ea7Python\u81ea\u52a8\u5316\u8fd0\u7ef4\u5b9e\u6218\uff08\u4e09\uff09\uff1a\u591a\u670d\u52a1\u5668\u5e76\u53d1\u5de1\u68c0\u4e0e\u67b6\u6784\u5347\u7ea7\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u4f01\u4e1a\u7ea7Python\u81ea\u52a8\u5316\u8fd0\u7ef4\u5b9e\u6218\uff08\u4e09\uff09\uff1a\u591a\u670d\u52a1\u5668\u5e76\u53d1\u5de1\u68c0\u4e0e\u67b6\u6784\u5347\u7ea7 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/92051.html","og_locale":"zh_CN","og_type":"article","og_title":"\u4f01\u4e1a\u7ea7Python\u81ea\u52a8\u5316\u8fd0\u7ef4\u5b9e\u6218\uff08\u4e09\uff09\uff1a\u591a\u670d\u52a1\u5668\u5e76\u53d1\u5de1\u68c0\u4e0e\u67b6\u6784\u5347\u7ea7 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u4e13\u680f\u7b80\u4ecb&#xff1a; \u672c\u4e13\u680f\u5c06\u4ece\u5355\u673a\u5de1\u68c0\u8d77\u6b65&#xff0c;\u9010\u6b65\u6f14\u8fdb\u5230\u591a\u673a\u6279\u91cf\u5de1\u68c0\u3001\u5f02\u5e38\u544a\u8b66\u63a8\u9001\u3001\u53ef\u89c6\u5316Dashboard&#xff0c;\u6700\u7ec8\u6784\u5efa\u4e00\u5957\u5b8c\u6574\u7684\u4f01\u4e1a\u7ea7\u81ea\u52a8\u5316\u8fd0\u7ef4\u5e73\u53f0\u3002\u6bcf\u4e00\u7bc7\u90fd\u662f\u751f\u4ea7\u73af\u5883\u5b9e\u6218\u6c89\u6dc0&#xff0c;\u62d2\u7edd\u62d2\u7eddHello World\u5f0f\u6559\u5b66\u3002 &#x1f4cc; \u672c\u7bc7\u5bfc\u8bfb \u5982\u679c\u6cbf\u7528\u4e0a\u4e00\u7bc7\u4f01\u4e1a\u7ea7Python\u81ea\u52a8\u5316\u8fd0\u7ef4\u5b9e\u6218&#xff08;\u4e8c&#xff09;&#xff1a;\u5355\u673a\u5347\u7ea7\u5230\u591a\u673a\u5de1\u68c0\u7cfb\u7edf&#xff0c;\u6211\u4eec\u9700\u8981\u5728\u6bcf\u53f0\u670d\u52a1\u5668\u4e0a\u90fd\u6267\u884c\u4e00\u904d&#xff0c;","og_url":"https:\/\/www.wsisp.com\/helps\/92051.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-08-08T21:08:36+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/92051.html","url":"https:\/\/www.wsisp.com\/helps\/92051.html","name":"\u4f01\u4e1a\u7ea7Python\u81ea\u52a8\u5316\u8fd0\u7ef4\u5b9e\u6218\uff08\u4e09\uff09\uff1a\u591a\u670d\u52a1\u5668\u5e76\u53d1\u5de1\u68c0\u4e0e\u67b6\u6784\u5347\u7ea7 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-08-08T21:08:36+00:00","dateModified":"2026-08-08T21:08:36+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/92051.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/92051.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/92051.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u4f01\u4e1a\u7ea7Python\u81ea\u52a8\u5316\u8fd0\u7ef4\u5b9e\u6218\uff08\u4e09\uff09\uff1a\u591a\u670d\u52a1\u5668\u5e76\u53d1\u5de1\u68c0\u4e0e\u67b6\u6784\u5347\u7ea7"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/92051","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=92051"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/92051\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=92051"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=92051"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=92051"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=92051"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}