{"id":204544,"date":"2025-05-29T12:28:58","date_gmt":"2025-05-29T04:28:58","guid":{"rendered":"https:\/\/server.hk\/cnblog\/204544\/"},"modified":"2025-05-29T12:28:58","modified_gmt":"2025-05-29T04:28:58","slug":"%e5%a6%82%e4%bd%95%e5%b0%86%e4%b8%a4%e4%b8%aa%e5%85%b7%e6%9c%89%e7%9b%b8%e5%90%8c%e9%94%ae%e7%9a%84%e5%ad%97%e5%85%b8%e5%90%88%e5%b9%b6%e4%b8%ba%e4%b8%80%e4%b8%aa%e6%96%b0%e7%9a%84%e5%ad%97%e5%85%b8","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/204544\/","title":{"rendered":"\u5982\u4f55\u5c06\u4e24\u4e2a\u5177\u6709\u76f8\u540c\u952e\u7684\u5b57\u5178\u5408\u5e76\u4e3a\u4e00\u4e2a\u65b0\u7684\u5b57\u5178\uff0c\u5176\u4e2d\u952e\u7684\u503c\u7531\u8fd9\u4e24\u4e2a\u5b57\u5178\u7684\u503c\u7ec4\u6210\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>\u5982\u4f55\u5c06\u4e24\u4e2a\u5177\u6709\u76f8\u540c\u952e\u7684\u5b57\u5178\u5408\u5e76\u4e3a\u4e00\u4e2a\u65b0\u7684\u5b57\u5178\uff0c\u5176\u4e2d\u952e\u7684\u503c\u7531\u8fd9\u4e24\u4e2a\u5b57\u5178\u7684\u503c\u7ec4\u6210\uff1f<\/h1>\n<p>\u6765\u5230\u7684\u5927\u5bb6\uff0c\u76f8\u4fe1\u90fd\u662f\u7f16\u7a0b\u5b66\u4e60\u7231\u597d\u8005\uff0c\u5e0c\u671b\u5728\u8fd9\u91cc\u5b66\u4e60\u6587\u7ae0\u76f8\u5173\u7f16\u7a0b\u77e5\u8bc6\u3002\u4e0b\u9762\u672c\u7bc7\u6587\u7ae0\u5c31\u6765\u5e26\u5927\u5bb6\u804a\u804a\u300a\u5982\u4f55\u5c06\u4e24\u4e2a\u5177\u6709\u76f8\u540c\u952e\u7684\u5b57\u5178\u5408\u5e76\u4e3a\u4e00\u4e2a\u65b0\u7684\u5b57\u5178\uff0c\u5176\u4e2d\u952e\u7684\u503c\u7531\u8fd9\u4e24\u4e2a\u5b57\u5178\u7684\u503c\u7ec4\u6210\uff1f\u300b\uff0c\u4ecb\u7ecd\u4e00\u4e0b\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u7684\u77e5\u8bc6\u79ef\u7d2f\u6709\u6240\u5e2e\u52a9\uff0c\u52a9\u529b\u5b9e\u6218\u5f00\u53d1\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241110\/17312135746730390643919.jpg\" class=\"aligncenter\"><\/p>\n<p><strong>python\u76f8\u540c\u952e\u7684\u4e24\u4e2a\u5b57\u5178\u5408\u5e76<\/strong><\/p>\n<p>\u672c\u6587\u5c06\u8ba8\u8bba\u5982\u4f55\u5c06\u4e24\u4e2a\u5177\u6709\u76f8\u540c\u952e\u7684\u5b57\u5178\u5408\u5e76\u4e3a\u4e00\u4e2a\u65b0\u7684\u5b57\u5178\uff0c\u5176\u4e2d\u952e\u7684\u503c\u7531\u8fd9\u4e24\u4e2a\u5b57\u5178\u7684\u503c\u7ec4\u6210\u3002<\/p>\n<p><strong>\u95ee\u9898<\/strong><\/p>\n<p>\u6211\u4eec\u6709\u4e24\u4e2a\u5b57\u5178\uff1a<\/p>\n<ul>\n<li>num_name\uff1a\u952e\u662f\u5b66\u751f\u5b66\u53f7\uff0c\u503c\u662f\u59d3\u540d\u3002<\/li>\n<li>num_bmi\uff1a\u952e\u662f\u5b66\u751f\u5b66\u53f7\uff0c\u503c\u662f bmi \u503c\u3002<\/li>\n<\/ul>\n<p>\u76ee\u6807\u662f\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5b57\u5178\uff0c\u5176\u4e2d\u952e\u662f\u5b66\u53f7\uff0c\u503c\u662f\u59d3\u540d\u548c bmi \u7ec4\u6210\u7684\u5143\u7ec4\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848<\/strong><\/p>\n<p>\u4e3a\u4e86\u5408\u5e76\u8fd9\u4e24\u4e2a\u5b57\u5178\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n<pre># \u521b\u5efa\u4e00\u4e2a\u65b0\u5b57\u5178\nnew = {}\n\n# \u904d\u5386 num_name \u4e2d\u7684\u6bcf\u4e2a\u952e\nfor i in num_name:\n    # \u904d\u5386 num_bmi \u4e2d\u7684\u6bcf\u4e2a\u952e\n    for j in num_bmi:\n        # \u5982\u679c\u4e24\u4e2a\u952e\u76f8\u540c\uff0c\u5219\u5c06\u59d3\u540d\u548c bmi \u503c\u6dfb\u52a0\u5230 new \u4e2d\n        if i == j:\n            new[i] = (num_name[i], num_bmi[j])\n\n# \u6253\u5370 new \u5b57\u5178\nprint(new)<\/pre>\n<p><strong>\u6539\u8fdb\u540e\u7684\u4ee3\u7801<\/strong><\/p>\n<pre>num_name = {100: \"\u738b\u4e00\", 101: \"\u674e\u4e8c\", 102: \"\u5f20\u4e09\", 103: \"\u94b1\u56db\", 104: \"\u5b59\u4e94\", 105: \"\u9a6c\u516d\"}\nnum_bmi = {102: 25.8, 100: 18, 105: 21, 104: 22}\n\nnew = {}\n\nfor i in num_name:\n    for j in num_bmi:\n        if i == j:\n            new[i] = (num_name[i], num_bmi[i])\n\nprint(new)<\/pre>\n<p>\u4e0a\u9762\u7684\u4ee3\u7801\u5c06\u6210\u529f\u5408\u5e76\u8fd9\u4e24\u4e2a\u5b57\u5178\u5e76\u6253\u5370\u51fa\u4ee5\u4e0b\u7ed3\u679c\uff1a<\/p>\n<pre>{100: ('\u738b\u4e00', 18), 102: ('\u5f20\u4e09', 25.8), 104: ('\u5b59\u4e94', 22), 105: ('\u9a6c\u516d', 21)}<\/pre>\n<p>\u4eca\u5929\u5173\u4e8e\u300a\u5982\u4f55\u5c06\u4e24\u4e2a\u5177\u6709\u76f8\u540c\u952e\u7684\u5b57\u5178\u5408\u5e76\u4e3a\u4e00\u4e2a\u65b0\u7684\u5b57\u5178\uff0c\u5176\u4e2d\u952e\u7684\u503c\u7531\u8fd9\u4e24\u4e2a\u5b57\u5178\u7684\u503c\u7ec4\u6210\uff1f\u300b\u7684\u5185\u5bb9\u4ecb\u7ecd\u5c31\u5230\u6b64\u7ed3\u675f\uff0c\u5982\u679c\u6709\u4ec0\u4e48\u7591\u95ee\u6216\u8005\u5efa\u8bae\uff0c\u53ef\u4ee5\u5728\u516c\u4f17\u53f7\u4e0b\u591a\u591a\u56de\u590d\u4ea4\u6d41\uff1b\u6587\u4e2d\u82e5\u6709\u4e0d\u6b63\u4e4b\u5904\uff0c\u4e5f\u5e0c\u671b\u56de\u590d\u7559\u8a00\u4ee5\u544a\u77e5\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u5c06\u4e24\u4e2a\u5177\u6709\u76f8\u540c\u952e\u7684\u5b57\u5178\u5408\u5e76\u4e3a&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4925],"tags":[],"class_list":["post-204544","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/204544","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=204544"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/204544\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=204544"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=204544"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=204544"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}