{"id":204820,"date":"2025-05-29T16:34:22","date_gmt":"2025-05-29T08:34:22","guid":{"rendered":"https:\/\/server.hk\/cnblog\/204820\/"},"modified":"2025-05-29T16:34:22","modified_gmt":"2025-05-29T08:34:22","slug":"python-%e5%87%bd%e6%95%b0%e4%bf%ae%e6%94%b9%e5%88%97%e8%a1%a8%ef%bc%8c%e4%b8%ba%e4%bb%80%e4%b9%88%e5%8e%9f%e5%88%97%e8%a1%a8%e6%b2%a1%e6%9c%89%e5%8f%98%e5%8c%96%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/204820\/","title":{"rendered":"Python \u51fd\u6570\u4fee\u6539\u5217\u8868\uff0c\u4e3a\u4ec0\u4e48\u539f\u5217\u8868\u6ca1\u6709\u53d8\u5316\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>Python \u51fd\u6570\u4fee\u6539\u5217\u8868\uff0c\u4e3a\u4ec0\u4e48\u539f\u5217\u8868\u6ca1\u6709\u53d8\u5316\uff1f<\/h1>\n<p>\u5728IT\u884c\u4e1a\u8fd9\u4e2a\u53d1\u5c55\u66f4\u65b0\u901f\u5ea6\u5f88\u5feb\u7684\u884c\u4e1a\uff0c\u53ea\u6709\u4e0d\u505c\u6b62\u7684\u5b66\u4e60\uff0c\u624d\u4e0d\u4f1a\u88ab\u884c\u4e1a\u6240\u6dd8\u6c70\u3002\u5982\u679c\u4f60\u662f\u6587\u7ae0\u5b66\u4e60\u8005\uff0c\u90a3\u4e48\u672c\u6587\u300aPython \u51fd\u6570\u4fee\u6539\u5217\u8868\uff0c\u4e3a\u4ec0\u4e48\u539f\u5217\u8868\u6ca1\u6709\u53d8\u5316\uff1f\u300b\u5c31\u5f88\u9002\u5408\u4f60\uff01\u672c\u7bc7\u5185\u5bb9\u4e3b\u8981\u5305\u62ec##content_title##\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\/20241117\/173181189867395a3a7a66b.jpg\" class=\"aligncenter\"><\/p>\n<p><strong>\u51fd\u6570\u4ea4\u4e92\u7591\u60d1\u89e3\u60d1<\/strong><\/p>\n<p>\u4f5c\u4e3a\u6587\u79d1\u96f6\u57fa\u7840\u7684\u5c0f\u767d\uff0c\u5728\u5b66\u4e60 python \u51fd\u6570\u65f6\u53ef\u80fd\u4f1a\u9047\u5230\u4e00\u4e9b\u7591\u60d1\u3002\u672c\u6587\u5c06\u89e3\u6790\u4e00\u4e2a\u5177\u4f53\u7684\u95ee\u9898\uff0c\u5e2e\u52a9\u4f60\u6df1\u5165\u7406\u89e3\u51fd\u6570\u7684\u7528\u6cd5\u3002<\/p>\n<p><strong>\u95ee\u9898<\/strong><\/p>\n<p>\u5728\u4ee5\u4e0b\u4ee3\u7801\u4e2d\uff0c\u5e0c\u671b\u5148\u901a\u8fc7\u51fd\u6570 make_great \u4fee\u6539\u5217\u8868 names\uff0c\u518d\u4f7f\u7528\u51fd\u6570 show_magicians \u663e\u793a\u4fee\u6539\u540e\u7684\u7ed3\u679c\u3002\u4f46\u662f\u5b9e\u9645\u8fd0\u884c\u65f6\uff0cnames \u5e76\u672a\u88ab\u4fee\u6539\u3002\u8fd9\u662f\u4e3a\u4ec0\u4e48\uff1f<\/p>\n<pre>def make_great(names):\n    for name in names:\n        name_1 = \"the great \" + name.title()\n        print(name_1)\ndef show_magicians(names):\n    for name in names:\n        print(name.title())\nnames = [\"a\", \"b\", \"c\", \"tutu\", \"mumu\"]\nmake_great(names)\nshow_magicians(names)<\/pre>\n<p><strong>\u89e3\u7b54<\/strong><\/p>\n<p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u51fd\u6570 make_great \u60f3\u8981\u4fee\u6539 names \u5217\u8868\uff0c\u4f46\u5b83\u5e76\u4e0d\u4f1a\u5b9e\u9645\u4fee\u6539\u539f\u6709\u5217\u8868\u3002\u5b83\u53ea\u662f\u5728\u5faa\u73af\u5185\u90e8\u521b\u5efa\u4e86\u4e00\u4e2a\u65b0\u7684\u53d8\u91cf name_1\uff0c\u5e76\u5411\u5176\u4e2d\u6dfb\u52a0\u4e86\u4fee\u9970\u7b26\u3002<\/p>\n<p>\u8981\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u4e00\u79cd\u65b9\u6cd5\u662f\u4f7f\u7528 python \u7684 map \u51fd\u6570\u3002map \u51fd\u6570\u5c06\u4e00\u4e2a\u51fd\u6570\u5e94\u7528\u4e8e\u53ef\u8fed\u4ee3\u5bf9\u8c61\u7684\u6bcf\u4e2a\u5143\u7d20\uff0c\u5e76\u8fd4\u56de\u4e00\u4e2a\u65b0\u5bf9\u8c61\u3002\u6211\u4eec\u53ef\u4ee5\u5229\u7528\u5b83\u6765\u4fee\u6539 names \u5217\u8868\u3002<\/p>\n<pre>def make_great(names):\n    return map(lambda name: \"the Great \" + name.title(), names)\ndef show_magicians(names):\n    for name in names:\n        print(name.title())\nnames = [\"A\", \"b\", \"c\", \"tutu\", \"mumu\"]\n\nshow_magicians(make_great(names))<\/pre>\n<p>\u5728\u8fd9\u4e2a\u4fee\u6539\u540e\u7684\u4ee3\u7801\u4e2d\uff0cmake_great \u51fd\u6570\u4f7f\u7528 map \u51fd\u6570\u8fd4\u56de\u4e00\u4e2a\u65b0\u7684\u5bf9\u8c61\uff0c\u8be5\u5bf9\u8c61\u5305\u542b\u4e86\u4fee\u6539\u540e\u7684\u540d\u79f0\u3002\u7136\u540e\u5c06\u8be5\u65b0\u5bf9\u8c61\u4f20\u9012\u7ed9 show_magicians \u51fd\u6570\uff0c\u4ece\u800c\u5b9e\u73b0\u4e86\u51fd\u6570\u4e4b\u95f4\u7684\u4ea4\u4e92\u3002<\/p>\n<p>\u672c\u7bc7\u5173\u4e8e\u300aPython \u51fd\u6570\u4fee\u6539\u5217\u8868\uff0c\u4e3a\u4ec0\u4e48\u539f\u5217\u8868\u6ca1\u6709\u53d8\u5316\uff1f\u300b\u7684\u4ecb\u7ecd\u5c31\u5230\u6b64\u7ed3\u675f\u5566\uff0c\u4f46\u662f\u5b66\u65e0\u6b62\u5883\uff0c\u60f3\u8981\u4e86\u89e3\u5b66\u4e60\u66f4\u591a\u5173\u4e8e\u6587\u7ae0\u7684\u76f8\u5173\u77e5\u8bc6\uff0c\u8bf7\u5173\u6ce8\u516c\u4f17\u53f7\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Python \u51fd\u6570\u4fee\u6539\u5217\u8868\uff0c\u4e3a\u4ec0&#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-204820","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/204820","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=204820"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/204820\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=204820"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=204820"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=204820"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}