{"id":25456,"date":"2025-04-19T12:37:03","date_gmt":"2025-04-19T04:37:03","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/25456.html"},"modified":"2025-04-19T12:37:03","modified_gmt":"2025-04-19T04:37:03","slug":"%e3%80%90python%e8%bf%9b%e9%98%b6%e3%80%91python%e7%bd%91%e7%bb%9c%e5%8d%8f%e8%ae%ae%e4%b8%8e%e5%a5%97%e6%8e%a5%e5%ad%97%e7%bc%96%e7%a8%8b%ef%bc%9a%e6%9e%84%e5%bb%ba%e5%ae%a2%e6%88%b7%e7%ab%af","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/25456.html","title":{"rendered":"\u3010Python\u8fdb\u9636\u3011Python\u7f51\u7edc\u534f\u8bae\u4e0e\u5957\u63a5\u5b57\u7f16\u7a0b\uff1a\u6784\u5efa\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668"},"content":{"rendered":"<h2>1\u3001\u7f51\u7edc\u901a\u4fe1\u57fa\u7840\u4e0e\u7f51\u7edc\u534f\u8bae<\/h2>\n<h3>1.1 \u7f51\u7edc\u901a\u4fe1\u6a21\u578b\u6982\u8ff0<\/h3>\n<p>\u7f51\u7edc\u901a\u4fe1\u662f\u4fe1\u606f\u65f6\u4ee3\u57fa\u77f3\uff0c\u5b83\u5982\u540c\u73b0\u5b9e\u4e16\u754c\u4e2d\u7684\u90ae\u9012\u7cfb\u7edf\uff0c\u5c06\u6570\u636e\u4ece\u4e00\u5904\u4f20\u9012\u5230\u53e6\u4e00\u5904\u3002\u5176\u4e2d\uff0cOSI\u4e03\u5c42\u6a21\u578b\u4e0eTCP\/IP\u56db\u5c42\u6216\u4e94\u5c42\u6a21\u578b\u662f\u7406\u89e3\u548c\u6784\u5efa\u7f51\u7edc\u901a\u4fe1\u7684\u57fa\u7840\u3002<\/p>\n<h4>1.1.1 OSI\u4e03\u5c42\u6a21\u578b\u4e0eTCP\/IP\u56db\u5c42\/\u4e94\u5c42\u6a21\u578b<\/h4>\n<p>OSI\uff08\u5f00\u653e\u7cfb\u7edf\u4e92\u8fde\uff09\u53c2\u8003\u6a21\u578b\u63d0\u51fa\u4e86\u4e03\u5c42\u7ed3\u6784\uff0c\u4ece\u7269\u7406\u5c42\u5230\u5e94\u7528\u5c42\uff0c\u6bcf\u4e00\u5c42\u90fd\u6709\u5176\u7279\u5b9a\u7684\u529f\u80fd\u548c\u804c\u8d23\uff0c\u4f8b\u5982\u7269\u7406\u5c42\u5173\u6ce8\u7684\u662f\u4fe1\u53f7\u5982\u4f55\u5728\u4ecb\u8d28\u4e0a\u4f20\u8f93\uff0c\u800c\u5e94\u7528\u5c42\u5219\u5904\u7406\u5177\u4f53\u7684\u5e94\u7528\u7a0b\u5e8f\u4ea4\u4e92\u3002<\/p>\n<p>\u76f8\u6bd4\u4e4b\u4e0b\uff0cTCP\/IP\u6a21\u578b\u66f4\u4e3a\u7b80\u6d01\u5b9e\u7528\uff0c\u901a\u5e38\u5206\u4e3a\u7f51\u7edc\u63a5\u53e3\u5c42\u3001\u7f51\u7edc\u5c42\u3001\u4f20\u8f93\u5c42\u548c\u5e94\u7528\u5c42\u56db\u5c42\uff08\u4e5f\u6709\u5c06\u5176\u8fdb\u4e00\u6b65\u5212\u5206\u4e3a\u4e94\u5c42\uff0c\u589e\u52a0\u4f1a\u8bdd\u5c42\u548c\u8868\u793a\u5c42\uff09\u3002TCP\/IP\u6a21\u578b\u6e90\u4e8e\u4e92\u8054\u7f51\u7684\u5b9e\u9645\u53d1\u5c55\uff0c\u5176\u4e2dIP\u534f\u8bae\u8d1f\u8d23\u7f51\u7edc\u5c42\u5bfb\u5740\u548c\u8def\u7531\u9009\u62e9\uff0cTCP\u534f\u8bae\u786e\u4fdd\u4f20\u8f93\u5c42\u7684\u6570\u636e\u53ef\u9760\u4f20\u8f93\u3002<\/p>\n<p>\u4f8b\u5982\uff0c\u5728\u53d1\u9001\u7535\u5b50\u90ae\u4ef6\u65f6\uff0c\u5e94\u7528\u5c42\uff08\u5982SMTP\u534f\u8bae\uff09\u8d1f\u8d23\u6784\u9020\u90ae\u4ef6\u5185\u5bb9\uff0c\u4f20\u8f93\u5c42\u7684TCP\u4fdd\u8bc1\u90ae\u4ef6\u6570\u636e\u6709\u5e8f\u3001\u65e0\u9519\u5730\u4f20\u8f93\uff0c\u800cIP\u534f\u8bae\u5219\u8d1f\u8d23\u90ae\u4ef6\u5728\u5168\u7403\u4e92\u8054\u7f51\u4e0a\u7684\u5bfb\u5740\u548c\u6295\u9012\u3002<\/p>\n<h4>1.1.2 \u4e3b\u8981\u7f51\u7edc\u534f\u8bae\u5c42\u6b21\u53ca\u5176\u529f\u80fd<\/h4>\n<p>\u7269\u7406\u5c42\uff1a\u5b9a\u4e49\u4e86\u7f51\u7edc\u8bbe\u5907\u4e4b\u95f4\u5982\u4f55\u901a\u8fc7\u7535\u4fe1\u53f7\u3001\u5149\u4fe1\u53f7\u7b49\u65b9\u5f0f\u4f20\u8f93\u539f\u59cb\u6bd4\u7279\u6d41\u3002 \u793a\u4f8b\u4ee3\u7801\uff08\u975e\u771f\u5b9e\u4ee3\u7801\uff0c\u4ec5\u4e3a\u793a\u610f\uff09\uff1a<\/p>\n<p><span class=\"token comment\"># \u5047\u8bbe\u6709\u4e00\u4e2a\u7b80\u5355\u7684\u6a21\u62df\u4fe1\u53f7\u53d1\u751f\u5668<\/span><br \/>\n<span class=\"token keyword\">class<\/span> <span class=\"token class-name\">SignalGenerator<\/span><span class=\"token punctuation\">:<\/span><br \/>\n  <span class=\"token keyword\">def<\/span> <span class=\"token function\">transmit_bits<\/span><span class=\"token punctuation\">(<\/span>self<span class=\"token punctuation\">,<\/span> bits<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n      <span class=\"token comment\"># \u53d1\u9001\u4e00\u7ec4\u6bd4\u7279\u6d41\u5230\u7269\u7406\u5a92\u4ecb<\/span><br \/>\n      <span class=\"token keyword\">pass<\/span><\/p>\n<p>\u6570\u636e\u94fe\u8def\u5c42\uff1a\u5c01\u88c5\u6210\u5e27\uff0c\u9519\u8bef\u68c0\u6d4b\uff0cMAC\u5730\u5740\u8bc6\u522b\u7b49\uff0c\u5982\u4ee5\u592a\u7f51\u534f\u8bae\u3002 \u7f51\u7edc\u5c42\uff1aIP\u534f\u8bae\u5728\u6b64\u5c42\u5de5\u4f5c\uff0c\u4e3b\u8981\u8d1f\u8d23\u5bfb\u5740\u548c\u8def\u7531\u9009\u62e9\uff0c\u51b3\u5b9a\u6570\u636e\u5305\u4ece\u6e90\u5230\u76ee\u7684\u5730\u7684\u6700\u4f73\u8def\u5f84\u3002<\/p>\n<p><span class=\"token keyword\">import<\/span> socket<\/p>\n<p><span class=\"token comment\"># \u521b\u5efa\u4e00\u4e2aIP\u5957\u63a5\u5b57<\/span><br \/>\nsock <span class=\"token operator\">=<\/span> socket<span class=\"token punctuation\">.<\/span>socket<span class=\"token punctuation\">(<\/span>socket<span class=\"token punctuation\">.<\/span>AF_INET<span class=\"token punctuation\">,<\/span> socket<span class=\"token punctuation\">.<\/span>SOCK_STREAM<span class=\"token punctuation\">)<\/span><br \/>\ndest_ip <span class=\"token operator\">=<\/span> <span class=\"token string\">\\&#8217;192.168.1.1\\&#8217;<\/span>  <span class=\"token comment\"># \u76ee\u6807IP\u5730\u5740<\/span><\/p>\n<p>\u4f20\u8f93\u5c42\uff1aTCP\u534f\u8bae\u63d0\u4f9b\u4e86\u9762\u5411\u8fde\u63a5\u3001\u53ef\u9760\u7684\u4f20\u8f93\u670d\u52a1\uff0cUDP\u534f\u8bae\u5219\u63d0\u4f9b\u4e86\u65e0\u8fde\u63a5\u3001\u4e0d\u53ef\u9760\u4f46\u901f\u5ea6\u5feb\u7684\u6570\u636e\u4f20\u8f93\u670d\u52a1\u3002 \u5e94\u7528\u5c42\uff1aHTTP\u3001FTP\u3001SMTP\u7b49\u5404\u79cd\u5e94\u7528\u7a0b\u5e8f\u4f7f\u7528\u7684\u534f\u8bae\u90fd\u4f4d\u4e8e\u8fd9\u4e00\u5c42\uff0c\u5b83\u4eec\u51b3\u5b9a\u4e86\u6570\u636e\u7684\u5177\u4f53\u5f62\u5f0f\u548c\u7528\u9014\u3002 \u901a\u8fc7\u8fd9\u4e9b\u5c42\u5c42\u53e0\u53e0\u7684\u534f\u8bae\u6808\uff0c\u6211\u4eec\u80fd\u591f\u6784\u5efa\u8d77\u4e30\u5bcc\u591a\u5f69\u7684\u7f51\u7edc\u5e94\u7528\uff0c\u65e0\u8bba\u662f\u7f51\u9875\u6d4f\u89c8\u3001\u6587\u4ef6\u4f20\u8f93\u8fd8\u662f\u5b9e\u65f6\u901a\u8baf\uff0c\u90fd\u79bb\u4e0d\u5f00\u8fd9\u4e9b\u57fa\u7840\u7f51\u7edc\u534f\u8bae\u7684\u652f\u6491\u3002<\/p>\n<h3>1.2 \u5e38\u89c1\u7f51\u7edc\u534f\u8bae\u7b80\u4ecb<\/h3>\n<h4>1.2.1 IP\u534f\u8bae\u4e0e\u8def\u7531\u9009\u62e9<\/h4>\n<p>IP\u534f\u8bae\u5982\u540c\u90ae\u653f\u7cfb\u7edf\u7684\u90ae\u7f16\u7cfb\u7edf\uff0c\u4e3a\u6bcf\u53f0\u8054\u7f51\u8bbe\u5907\u5206\u914d\u72ec\u4e00\u65e0\u4e8c\u7684IP\u5730\u5740\uff0c\u5e76\u4f7f\u7528\u8def\u7531\u8868\u6307\u5bfc\u6570\u636e\u5305\u5728\u7f51\u7edc\u4e2d\u5bfb\u627e\u5230\u8fbe\u76ee\u7684\u5730\u7684\u6700\u4f73\u8def\u5f84\u3002\u6bd4\u5982\uff0c\u5f53\u4f60\u5728\u7f51\u4e0a\u51b2\u6d6a\u65f6\uff0c\u4f60\u7684\u7535\u8111\u5c31\u662f\u901a\u8fc7IP\u534f\u8bae\u5c06\u8bf7\u6c42\u53d1\u9001\u5230\u5168\u7403\u5404\u5730\u7684\u670d\u52a1\u5668\u3002<\/p>\n<p><span class=\"token comment\"># \u83b7\u53d6\u672c\u5730\u4e3b\u673aIP\u5730\u5740<\/span><br \/>\n<span class=\"token keyword\">import<\/span> socket<br \/>\nlocal_ip <span class=\"token operator\">=<\/span> socket<span class=\"token punctuation\">.<\/span>gethostbyname<span class=\"token punctuation\">(<\/span>socket<span class=\"token punctuation\">.<\/span>gethostname<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string-interpolation\"><span class=\"token string\">f\\&#8221;\u672c\u673aIP\u5730\u5740: <\/span><span class=\"token interpolation\"><span class=\"token punctuation\">{<br \/>\n     <\/span>local_ip<span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">\\&#8221;<\/span><\/span><span class=\"token punctuation\">)<\/span><\/p>\n<h4>1.2.2 TCP\u534f\u8bae\u4e0e\u53ef\u9760\u6027\u4f20\u8f93<\/h4>\n<p>TCP\u534f\u8bae\u50cf\u662f\u4e00\u4f4d\u4e25\u8c28\u7684\u5feb\u9012\u5458\uff0c\u4ed6\u4e0d\u4ec5\u786e\u4fdd\u6bcf\u4e2a\u5305\u88f9\u90fd\u80fd\u9001\u8fbe\uff0c\u8fd8\u786e\u4fdd\u5305\u88f9\u6309\u987a\u5e8f\u5230\u8fbe\uff0c\u5982\u6709\u4e22\u5931\u6216\u635f\u574f\uff0c\u8fd8\u4f1a\u91cd\u65b0\u53d1\u9001\u3002TCP\u901a\u8fc7\u63e1\u624b\u5efa\u7acb\u8fde\u63a5\uff0c\u901a\u8fc7\u5e8f\u5217\u53f7\u548c\u786e\u8ba4\u5e94\u7b54\u4fdd\u8bc1\u6570\u636e\u53ef\u9760\u4f20\u8f93\u3002<\/p>\n<p><span class=\"token comment\"># Python\u4e2d\u521b\u5efaTCP\u670d\u52a1\u5668\u7aef<\/span><br \/>\nserver_sock <span class=\"token operator\">=<\/span> socket<span class=\"token punctuation\">.<\/span>socket<span class=\"token punctuation\">(<\/span>socket<span class=\"token punctuation\">.<\/span>AF_INET<span class=\"token punctuation\">,<\/span> socket<span class=\"token punctuation\">.<\/span>SOCK_STREAM<span class=\"token punctuation\">)<\/span><br \/>\nserver_sock<span class=\"token punctuation\">.<\/span>bind<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">\\&#8217;localhost\\&#8217;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">12345<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\"># \u7ed1\u5b9a\u672c\u5730IP\u548c\u7aef\u53e3<\/span><br \/>\nserver_sock<span class=\"token punctuation\">.<\/span>listen<span class=\"token punctuation\">(<\/span><span class=\"token number\">5<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\"># \u5f00\u59cb\u76d1\u542c\u8fde\u63a5\u8bf7\u6c42<\/span><br \/>\nconn<span class=\"token punctuation\">,<\/span> addr <span class=\"token operator\">=<\/span> server_sock<span class=\"token punctuation\">.<\/span>accept<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\"># \u7b49\u5f85\u5e76\u63a5\u53d7\u5ba2\u6237\u7aef\u8fde\u63a5<\/span><br \/>\n<span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">.<\/span><\/p>\n<p><span class=\"token comment\"># \u5ba2\u6237\u7aef\u4e0e\u670d\u52a1\u5668\u7aef\u4e4b\u95f4\u7684\u6570\u636e\u4f20\u8f93<\/span><br \/>\ndata <span class=\"token operator\">=<\/span> conn<span class=\"token punctuation\">.<\/span>recv<span class=\"token punctuation\">(<\/span><span class=\"token number\">1024<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\"># \u63a5\u6536\u6570\u636e<\/span><br \/>\nconn<span class=\"token punctuation\">.<\/span>sendall<span class=\"token punctuation\">(<\/span><span class=\"token string\">b\\&#8217;ACK! Data received.\\&#8217;<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\"># \u5411\u670d\u52a1\u5668\u53d1\u9001\u786e\u8ba4\u4fe1\u606f<\/span><\/p>\n<h4>1.2.3 UDP\u534f\u8bae\u4e0e\u65e0\u8fde\u63a5\u6570\u636e\u4f20\u8f93<\/h4>\n<p>UDP\u534f\u8bae\u5219\u66f4\u50cf\u4e00\u4f4d\u6025\u6027\u5b50\u7684\u6295\u9012\u5458\uff0c\u4e00\u65e6\u63a5\u6536\u5230\u6570\u636e\u5c31\u7acb\u5373\u6295\u9012\uff0c\u4e0d\u5173\u5fc3\u662f\u5426\u9001\u8fbe\u53ca\u987a\u5e8f\uff0c\u56e0\u6b64\u901f\u5ea6\u66f4\u5feb\uff0c\u5e38\u7528\u4e8e\u5bf9\u5ef6\u8fdf\u654f\u611f\u7684\u5e94\u7528\uff0c\u5982\u5728\u7ebf\u89c6\u9891\u4f1a\u8bae\u3001\u5b9e\u65f6\u6e38\u620f\u7b49\u573a\u666f\u3002<\/p>\n<p><span class=\"token comment\"># Python\u4e2d\u521b\u5efaUDP\u5957\u63a5\u5b57<\/span><br \/>\nudp_socket <span class=\"token operator\">=<\/span> socket<span class=\"token punctuation\">.<\/span>socket<span class=\"token punctuation\">(<\/span>socket<span class=\"token punctuation\">.<\/span>AF_INET<span class=\"token punctuation\">,<\/span> socket<span class=\"token punctuation\">.<\/span>SOCK_DGRAM<span class=\"token punctuation\">)<\/span><br \/>\nmessage <span class=\"token operator\">=<\/span> <span class=\"token string\">b\\&#8217;Hello, UDP world!\\&#8217;<\/span><br \/>\nudp_socket<span class=\"token punctuation\">.<\/span>sendto<span class=\"token punctuation\">(<\/span>message<span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token string\">\\&#8217;localhost\\&#8217;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">5005<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\"># \u53d1\u9001\u6570\u636e\u62a5\u6587\u5230\u6307\u5b9a\u5730\u5740<\/span><br \/>\ndata<span class=\"token punctuation\">,<\/span> addr <span class=\"token operator\">=<\/span> udp_socket<span class=\"token punctuation\">.<\/span>recvfrom<span class=\"token punctuation\">(<\/span><span class=\"token number\">1024<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\"># \u63a5\u6536\u4efb\u610f\u6765\u6e90\u7684\u6570\u636e\u62a5\u6587<\/span><\/p>\n<h2>2\u3001Python\u4e2d\u7684\u7f51\u7edc\u7f16\u7a0b\u57fa\u7840<\/h2>\n<h3>2.1 Python socket\u6a21\u5757\u4ecb\u7ecd<\/h3>\n<h4>2.1.1 socket\u5bf9\u8c61\u7684\u521b\u5efa\u4e0e\u5c5e\u6027<\/h4>\n<p>\u5728Python\u4e2d\uff0csocket\u6a21\u5757\u662f\u8fdb\u884c\u7f51\u7edc\u7f16\u7a0b\u7684\u6838\u5fc3\u5de5\u5177\uff0c\u5b83\u63d0\u4f9b\u4e86\u4e00\u79cd\u6807\u51c6\u7684\u65b9\u5f0f\u6765\u521b\u5efa\u3001\u914d\u7f6e\u5e76\u7ba1\u7406\u5957\u63a5\u5b57\u3002\u60f3\u8c61\u4e00\u4e0b\uff0c\u5957\u63a5\u5b57\u5c31\u50cf\u662f\u4e00\u6247\u95e8\uff0c\u5141\u8bb8\u4f60\u7684\u7a0b\u5e8f\u63a5\u5165\u4e92\u8054\u7f51\u8fd9\u6761\u5927\u8def\uff0c\u4e0e\u5176\u4ed6\u8fdc\u7a0b\u4e3b\u673a\u8fdb\u884c\u4ea4\u6d41\u3002<\/p>\n<p>\u521b\u5efa\u4e00\u4e2a\u65b0\u7684socket\u5bf9\u8c61\u5c31\u50cf\u5f00\u542f\u8fd9\u6247\u95e8\u4e00\u6837\u7b80\u5355\uff0c\u4f60\u53ef\u4ee5\u6839\u636e\u9700\u8981\u9009\u62e9\u4e0d\u540c\u7684\u5730\u5740\u5bb6\u65cf\u548c\u534f\u8bae\u7c7b\u578b\u3002\u4f8b\u5982\uff0c\u521b\u5efa\u4e00\u4e2aIPv4\u73af\u5883\u4e0b\u7684TCP\u5957\u63a5\u5b57\uff1a<\/p>\n<p><span class=\"token keyword\">import<\/span> socket<\/p>\n<p><span class=\"token comment\"># \u521b\u5efa\u4e00\u4e2aTCP\u5957\u63a5\u5b57<\/span><br \/>\ntcp_socket <span class=\"token operator\">=<\/span> socket<span class=\"token punctuation\">.<\/span>socket<span class=\"token punctuation\">(<\/span>socket<span class=\"token punctuation\">.<\/span>AF_INET<span class=\"token punctuation\">,<\/span> socket<span class=\"token punctuation\">.<\/span>SOCK_STREAM<span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token comment\"># \u663e\u793a\u5957\u63a5\u5b57\u7684\u4e00\u4e9b\u57fa\u672c\u4fe1\u606f<\/span><br \/>\n<span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string-interpolation\"><span class=\"token string\">f\\&#8221;Socket type: <\/span><span class=\"token interpolation\"><span class=\"token punctuation\">{<br \/>\n     <\/span>tcp_socket<span class=\"token punctuation\">.<\/span><span class=\"token builtin\">type<\/span><span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">\\&#8221;<\/span><\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string-interpolation\"><span class=\"token string\">f\\&#8221;Socket family: <\/span><span class=\"token interpolation\"><span class=\"token punctuation\">{<br \/>\n     <\/span>tcp_socket<span class=\"token punctuation\">.<\/span>family<span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">\\&#8221;<\/span><\/span><span class=\"token punctuation\">)<\/span><\/p>\n<h4>2.1.2 Python\u4e2d\u7684\u5730\u5740\u5bb6\u65cf\u4e0e\u534f\u8bae\u7c7b\u578b<\/h4>\n<p>\u5730\u5740\u5bb6\u65cf\uff1a\u4e3b\u8981\u5305\u62ec\u4e24\u79cd\u7c7b\u578b\uff0cAF_INET\uff08IPv4\uff09\u548cAF_INET6\uff08IPv6\uff09\uff0c\u5206\u522b\u5bf9\u5e94\u4e0d\u540c\u7248\u672c\u7684Internet\u534f\u8bae\u5730\u5740\u3002 \u534f\u8bae\u7c7b\u578b\uff1a\u4e3b\u8981\u6709\u4e24\u79cd\uff0cSOCK_STREAM\uff08TCP\uff09\u548cSOCK_DGRAM\uff08UDP\uff09\u3002TCP\u63d0\u4f9b\u9762\u5411\u8fde\u63a5\u3001\u53ef\u9760\u7684\u6570\u636e\u4f20\u8f93\u670d\u52a1\uff1bUDP\u5219\u63d0\u4f9b\u65e0\u8fde\u63a5\u3001\u5feb\u901f\u4f46\u53ef\u80fd\u4e22\u5305\u6216\u4e71\u5e8f\u7684\u6570\u636e\u4f20\u8f93\u670d\u52a1\u3002<\/p>\n<h3>2.2 Python\u4e2d\u7684TCP\u5957\u63a5\u5b57\u7f16\u7a0b<\/h3>\n<h4>2.2.1 TCP\u670d\u52a1\u5668\u7aef\u5f00\u53d1\u6b65\u9aa4<\/h4>\n<h5>2.2.1.1 \u7ed1\u5b9a\u5730\u5740\u4e0e\u76d1\u542c\u8fde\u63a5<\/h5>\n<p>\u9996\u5148\uff0c\u670d\u52a1\u5668\u9700\u8981\u7ed1\u5b9a\u4e00\u4e2a\u672c\u5730\u5730\u5740\uff08IP\u5730\u5740\u548c\u7aef\u53e3\u53f7\uff09\u6765\u76d1\u542c\u5ba2\u6237\u7aef\u7684\u8fde\u63a5\u8bf7\u6c42\u3002\u4f8b\u5982\uff0c\u6211\u4eec\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u76d1\u542c\u672c\u57308000\u7aef\u53e3\u7684TCP\u670d\u52a1\u5668\uff1a<\/p>\n<p>server_socket <span class=\"token operator\">=<\/span> socket<span class=\"token punctuation\">.<\/span>socket<span class=\"token punctuation\">(<\/span>socket<span class=\"token punctuation\">.<\/span>AF_INET<span class=\"token punctuation\">,<\/span> socket<span class=\"token punctuation\">.<\/span>SOCK_STREAM<span class=\"token punctuation\">)<\/span><br \/>\nserver_socket<span class=\"token punctuation\">.<\/span>bind<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">\\&#8217;localhost\\&#8217;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">8000<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><br \/>\nserver_socket<span class=\"token punctuation\">.<\/span>listen<span class=\"token punctuation\">(<\/span><span class=\"token number\">5<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\"># \u8bbe\u7f6e\u6700\u5927\u6302\u8d77\u8fde\u63a5\u6570\u4e3a5<\/span><\/p>\n<p><span class=\"token keyword\">while<\/span> <span class=\"token boolean\">True<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    client_socket<span class=\"token punctuation\">,<\/span> client_address <span class=\"token operator\">=<\/span> server_socket<span class=\"token punctuation\">.<\/span>accept<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string-interpolation\"><span class=\"token string\">f\\&#8221;Accepted connection from <\/span><span class=\"token interpolation\"><span class=\"token punctuation\">{<br \/>\n     <\/span>client_address<span class=\"token punctuation\">[<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">:<\/span><span class=\"token interpolation\"><span class=\"token punctuation\">{<br \/>\n     <\/span>client_address<span class=\"token punctuation\">[<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">\\&#8221;<\/span><\/span><span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token comment\"># &#8230;\u6b64\u5904\u53ef\u4ee5\u5904\u7406\u6765\u81ea\u5ba2\u6237\u7aef\u7684\u6570\u636e&#8230;<\/span><\/p>\n<h5>2.2.1.2 \u63a5\u53d7\u5ba2\u6237\u7aef\u8fde\u63a5\u5e76\u901a\u4fe1<\/h5>\n<p>\u5f53\u6709\u5ba2\u6237\u7aef\u8fde\u63a5\u65f6\uff0caccept()\u65b9\u6cd5\u4f1a\u8fd4\u56de\u4e00\u4e2a\u65b0\u7684\u5957\u63a5\u5b57\uff0c\u7528\u4e8e\u4e0e\u8be5\u5ba2\u6237\u7aef\u8fdb\u884c\u5355\u72ec\u7684\u6570\u636e\u4ea4\u6362\uff1a<\/p>\n<p><span class=\"token comment\"># \u5728\u65b0\u7ebf\u7a0b\u4e2d\u5904\u7406\u5ba2\u6237\u7aef\u8fde\u63a5<\/span><br \/>\n<span class=\"token keyword\">def<\/span> <span class=\"token function\">handle_client<\/span><span class=\"token punctuation\">(<\/span>client_socket<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    message <span class=\"token operator\">=<\/span> client_socket<span class=\"token punctuation\">.<\/span>recv<span class=\"token punctuation\">(<\/span><span class=\"token number\">1024<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span>decode<span class=\"token punctuation\">(<\/span><span class=\"token string\">\\&#8217;utf-8\\&#8217;<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string-interpolation\"><span class=\"token string\">f\\&#8221;Received message: <\/span><span class=\"token interpolation\"><span class=\"token punctuation\">{<br \/>\n     <\/span>message<span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">\\&#8221;<\/span><\/span><span class=\"token punctuation\">)<\/span><br \/>\n    response <span class=\"token operator\">=<\/span> <span class=\"token string\">\\&#8221;Echo: \\&#8221;<\/span> <span class=\"token operator\">+<\/span> message<br \/>\n    client_socket<span class=\"token punctuation\">.<\/span>sendall<span class=\"token punctuation\">(<\/span>response<span class=\"token punctuation\">.<\/span>encode<span class=\"token punctuation\">(<\/span><span class=\"token string\">\\&#8217;utf-8\\&#8217;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    client_socket<span class=\"token punctuation\">.<\/span>close<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>new_thread <span class=\"token operator\">=<\/span> threading<span class=\"token punctuation\">.<\/span>Thread<span class=\"token punctuation\">(<\/span>target<span class=\"token operator\">=<\/span>handle_client<span class=\"token punctuation\">,<\/span> args<span class=\"token operator\">=<\/span><span class=\"token punctuation\">(<\/span>client_socket<span class=\"token punctuation\">,<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><br \/>\nnew_thread<span class=\"token punctuation\">.<\/span>start<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<h4>2.2.2 TCP\u5ba2\u6237\u7aef\u7f16\u7a0b\u5b9e\u8df5<\/h4>\n<h5>2.2.2.1 \u8fde\u63a5\u5230\u670d\u52a1\u5668\u5e76\u53d1\u9001\u6570\u636e<\/h5>\n<p>\u5ba2\u6237\u7aef\u9700\u8981\u77e5\u9053\u670d\u52a1\u5668\u7684\u5730\u5740\u548c\u7aef\u53e3\uff0c\u7136\u540e\u53d1\u8d77\u8fde\u63a5\u8bf7\u6c42\uff1a<\/p>\n<p>client_socket<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.5k\u6b21\uff0c\u70b9\u8d5e27\u6b21\uff0c\u6536\u85cf19\u6b21\u3002IP\u534f\u8bae\u5982\u540c\u90ae\u653f\u7cfb\u7edf\u7684\u90ae\u7f16\u7cfb\u7edf\uff0c\u4e3a\u6bcf\u53f0\u8054\u7f51\u8bbe\u5907\u5206\u914d\u72ec\u4e00\u65e0\u4e8c\u7684IP\u5730\u5740\uff0c\u5e76\u4f7f\u7528\u8def\u7531\u8868\u6307\u5bfc\u6570\u636e\u5305\u5728\u7f51\u7edc\u4e2d\u5bfb\u627e\u5230\u8fbe\u76ee\u7684\u5730\u7684\u6700\u4f73\u8def\u5f84\u3002\u6bd4\u5982\uff0c\u5f53\u4f60\u5728\u7f51\u4e0a\u51b2\u6d6a\u65f6\uff0c\u4f60\u7684\u7535\u8111\u5c31\u662f\u901a\u8fc7IP\u534f\u8bae\u5c06\u8bf7\u6c42\u53d1\u9001\u5230\u5168\u7403\u5404\u5730\u7684\u670d\u52a1\u5668\u3002# \u83b7\u53d6\u672c\u5730\u4e3b\u673aIP\u5730\u5740print(f&quot;\u672c\u673aIP\u5730\u5740:# \u83b7\u53d6\u672c\u5730\u4e3b\u673aIP\u5730\u5740 import socketlocal_ip = socket . gethostbyname(socket . gethostname()) print(f&quot;\u672c\u673aIP\u5730\u5740: {_python tcp\u670d\u52a1\u5668\u7aef<\/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,43,191],"topic":[],"class_list":["post-25456","post","type-post","status-publish","format-standard","hentry","category-server","tag-python","tag-43","tag-191"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u3010Python\u8fdb\u9636\u3011Python\u7f51\u7edc\u534f\u8bae\u4e0e\u5957\u63a5\u5b57\u7f16\u7a0b\uff1a\u6784\u5efa\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668 - \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\/25456.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u3010Python\u8fdb\u9636\u3011Python\u7f51\u7edc\u534f\u8bae\u4e0e\u5957\u63a5\u5b57\u7f16\u7a0b\uff1a\u6784\u5efa\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.5k\u6b21\uff0c\u70b9\u8d5e27\u6b21\uff0c\u6536\u85cf19\u6b21\u3002IP\u534f\u8bae\u5982\u540c\u90ae\u653f\u7cfb\u7edf\u7684\u90ae\u7f16\u7cfb\u7edf\uff0c\u4e3a\u6bcf\u53f0\u8054\u7f51\u8bbe\u5907\u5206\u914d\u72ec\u4e00\u65e0\u4e8c\u7684IP\u5730\u5740\uff0c\u5e76\u4f7f\u7528\u8def\u7531\u8868\u6307\u5bfc\u6570\u636e\u5305\u5728\u7f51\u7edc\u4e2d\u5bfb\u627e\u5230\u8fbe\u76ee\u7684\u5730\u7684\u6700\u4f73\u8def\u5f84\u3002\u6bd4\u5982\uff0c\u5f53\u4f60\u5728\u7f51\u4e0a\u51b2\u6d6a\u65f6\uff0c\u4f60\u7684\u7535\u8111\u5c31\u662f\u901a\u8fc7IP\u534f\u8bae\u5c06\u8bf7\u6c42\u53d1\u9001\u5230\u5168\u7403\u5404\u5730\u7684\u670d\u52a1\u5668\u3002# \u83b7\u53d6\u672c\u5730\u4e3b\u673aIP\u5730\u5740print(f&quot;\u672c\u673aIP\u5730\u5740:# \u83b7\u53d6\u672c\u5730\u4e3b\u673aIP\u5730\u5740 import socketlocal_ip = socket . gethostbyname(socket . gethostname()) print(f&quot;\u672c\u673aIP\u5730\u5740: {_python tcp\u670d\u52a1\u5668\u7aef\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/25456.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-19T04:37:03+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=\"1 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/25456.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/25456.html\",\"name\":\"\u3010Python\u8fdb\u9636\u3011Python\u7f51\u7edc\u534f\u8bae\u4e0e\u5957\u63a5\u5b57\u7f16\u7a0b\uff1a\u6784\u5efa\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-04-19T04:37:03+00:00\",\"dateModified\":\"2025-04-19T04:37:03+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/25456.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/25456.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/25456.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u3010Python\u8fdb\u9636\u3011Python\u7f51\u7edc\u534f\u8bae\u4e0e\u5957\u63a5\u5b57\u7f16\u7a0b\uff1a\u6784\u5efa\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668\"}]},{\"@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":"\u3010Python\u8fdb\u9636\u3011Python\u7f51\u7edc\u534f\u8bae\u4e0e\u5957\u63a5\u5b57\u7f16\u7a0b\uff1a\u6784\u5efa\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668 - \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\/25456.html","og_locale":"zh_CN","og_type":"article","og_title":"\u3010Python\u8fdb\u9636\u3011Python\u7f51\u7edc\u534f\u8bae\u4e0e\u5957\u63a5\u5b57\u7f16\u7a0b\uff1a\u6784\u5efa\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.5k\u6b21\uff0c\u70b9\u8d5e27\u6b21\uff0c\u6536\u85cf19\u6b21\u3002IP\u534f\u8bae\u5982\u540c\u90ae\u653f\u7cfb\u7edf\u7684\u90ae\u7f16\u7cfb\u7edf\uff0c\u4e3a\u6bcf\u53f0\u8054\u7f51\u8bbe\u5907\u5206\u914d\u72ec\u4e00\u65e0\u4e8c\u7684IP\u5730\u5740\uff0c\u5e76\u4f7f\u7528\u8def\u7531\u8868\u6307\u5bfc\u6570\u636e\u5305\u5728\u7f51\u7edc\u4e2d\u5bfb\u627e\u5230\u8fbe\u76ee\u7684\u5730\u7684\u6700\u4f73\u8def\u5f84\u3002\u6bd4\u5982\uff0c\u5f53\u4f60\u5728\u7f51\u4e0a\u51b2\u6d6a\u65f6\uff0c\u4f60\u7684\u7535\u8111\u5c31\u662f\u901a\u8fc7IP\u534f\u8bae\u5c06\u8bf7\u6c42\u53d1\u9001\u5230\u5168\u7403\u5404\u5730\u7684\u670d\u52a1\u5668\u3002# \u83b7\u53d6\u672c\u5730\u4e3b\u673aIP\u5730\u5740print(f&quot;\u672c\u673aIP\u5730\u5740:# \u83b7\u53d6\u672c\u5730\u4e3b\u673aIP\u5730\u5740 import socketlocal_ip = socket . gethostbyname(socket . gethostname()) print(f&quot;\u672c\u673aIP\u5730\u5740: {_python tcp\u670d\u52a1\u5668\u7aef","og_url":"https:\/\/www.wsisp.com\/helps\/25456.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-04-19T04:37:03+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/25456.html","url":"https:\/\/www.wsisp.com\/helps\/25456.html","name":"\u3010Python\u8fdb\u9636\u3011Python\u7f51\u7edc\u534f\u8bae\u4e0e\u5957\u63a5\u5b57\u7f16\u7a0b\uff1a\u6784\u5efa\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-04-19T04:37:03+00:00","dateModified":"2025-04-19T04:37:03+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/25456.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/25456.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/25456.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u3010Python\u8fdb\u9636\u3011Python\u7f51\u7edc\u534f\u8bae\u4e0e\u5957\u63a5\u5b57\u7f16\u7a0b\uff1a\u6784\u5efa\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668"}]},{"@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\/25456","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=25456"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/25456\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=25456"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=25456"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=25456"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=25456"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}