{"id":204827,"date":"2025-05-29T11:05:44","date_gmt":"2025-05-29T03:05:44","guid":{"rendered":"https:\/\/server.hk\/cnblog\/204827\/"},"modified":"2025-05-29T11:05:44","modified_gmt":"2025-05-29T03:05:44","slug":"python-%e5%87%bd%e6%95%b0%e4%b9%8b%e9%97%b4%e5%a6%82%e4%bd%95%e5%ae%9e%e7%8e%b0%e4%ba%a4%e4%ba%92%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/204827\/","title":{"rendered":"Python \u51fd\u6570\u4e4b\u95f4\u5982\u4f55\u5b9e\u73b0\u4ea4\u4e92\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>Python \u51fd\u6570\u4e4b\u95f4\u5982\u4f55\u5b9e\u73b0\u4ea4\u4e92\uff1f<\/h1>\n<p>\u54c8\u55bd\uff01\u4eca\u5929\u5fc3\u8840\u6765\u6f6e\u7ed9\u5927\u5bb6\u5e26\u6765\u4e86\uff0c\u60f3\u5fc5\u5927\u5bb6\u5e94\u8be5\u5bf9<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u6587\u7ae0<\/span>\u90fd\u4e0d\u964c\u751f\u5427\uff0c\u90a3\u4e48\u9605\u8bfb\u672c\u6587\u5c31\u90fd\u4e0d\u4f1a\u5f88\u56f0\u96be\uff0c\u4ee5\u4e0b\u5185\u5bb9\u4e3b\u8981\u6d89\u53ca\u5230<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\uff0c\u82e5\u662f\u4f60\u6b63\u5728\u5b66\u4e60<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u6587\u7ae0<\/span>\uff0c\u5343\u4e07\u522b\u9519\u8fc7\u8fd9\u7bc7\u6587\u7ae0~\u5e0c\u671b\u80fd\u5e2e\u52a9\u5230\u4f60\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241117\/173181712667396ea693093.jpg\" class=\"aligncenter\"><\/p>\n<p><strong>python \u51fd\u6570\u4ea4\u4e92\uff1a\u96f6\u57fa\u7840\u5c0f\u767d\u7684\u5e38\u89c1\u7591\u60d1<\/strong><\/p>\n<p>\u4f5c\u4e3a\u4e00\u540d\u521a\u63a5\u89e6 python \u51fd\u6570\u7684\u6587\u79d1\u751f\uff0c\u60a8\u53ef\u80fd\u4f1a\u9047\u5230\u4e00\u4e9b\u56f0\u60d1\u3002\u4f8b\u5982\uff0c\u60a8\u4e0d\u7981\u4f1a\u95ee\uff0c\u4e0d\u540c\u7684\u51fd\u6570\u4e4b\u95f4\u662f\u5426\u53ef\u4ee5\u76f8\u4e92\u4f5c\u7528\uff1f<\/p>\n<p>\u4e3a\u4e86\u63a2\u8ba8\u8fd9\u4e2a\u95ee\u9898\uff0c\u8ba9\u6211\u4eec examine \u4e0b\u9762\u7684\u4e00\u6bb5\u4ee3\u7801\uff1a<\/p>\n<pre>def make_great(names):\n    for name in names:\n        name_1 = \"the great \" + name.title()\n        print(name_1)\n\ndef show_magicians(names):\n    for name in names:\n        print(name.title())\n\nnames = [\"a\", \"b\", \"c\", \"tutu\", \"mumu\"]\nmake_great(names)\nshow_magicians(names)<\/pre>\n<p>\u6309\u7167\u8fd9\u79cd\u5199\u6cd5\uff0c\u60a8\u53ef\u80fd\u4f1a\u5e0c\u671b\u901a\u8fc7\u7b2c\u4e00\u4e2a\u51fd\u6570 make_great \u4fee\u6539\u5217\u8868 names\uff0c\u7136\u540e\u518d\u5728\u7b2c\u4e8c\u4e2a\u51fd\u6570 show_magicians \u4e2d\u663e\u793a\u4fee\u6539\u540e\u7684\u5217\u8868\u3002<\/p>\n<p><strong>\u7b54\u6848\uff1a\u4f7f\u7528 map \u51fd\u6570<\/strong><\/p>\n<p>\u8981\u5b9e\u73b0\u5728\u51fd\u6570\u4e4b\u95f4\u4f20\u9012\u8fd4\u56de\u503c\uff0c\u60a8\u53ef\u4ee5\u5229\u7528 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\u5305\u542b\u7ed3\u679c\u7684\u65b0\u53ef\u8fed\u4ee3\u5bf9\u8c61\u3002<\/p>\n<p>\u4fee\u6539\u540e\u7684\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre>def make_great(names):\n    return map(lambda name: \"the Great \" + name.title(), names)\n\ndef show_magicians(names):\n    for name in names:\n        print(name.title())\n\nnames = [\"A\", \"b\", \"c\", \"tutu\", \"mumu\"]\n\nshow_magicians(make_great(names))<\/pre>\n<p>\u901a\u8fc7\u5c06 make_great \u51fd\u6570\u7684\u8fd4\u56de\u503c\u4f5c\u4e3a show_magicians \u51fd\u6570\u7684\u53c2\u6570\uff0c\u6211\u4eec\u5b9e\u73b0\u4e86\u51fd\u6570\u4e4b\u95f4\u7684\u4ea4\u4e92\u3002<\/p>\n<p>\u597d\u4e86\uff0c\u672c\u6587\u5230\u6b64\u7ed3\u675f\uff0c\u5e26\u5927\u5bb6\u4e86\u89e3\u4e86\u300aPython \u51fd\u6570\u4e4b\u95f4\u5982\u4f55\u5b9e\u73b0\u4ea4\u4e92\uff1f\u300b\uff0c\u5e0c\u671b\u672c\u6587\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\uff01\u5173\u6ce8\u516c\u4f17\u53f7\uff0c\u7ed9\u5927\u5bb6\u5206\u4eab\u66f4\u591a\u6587\u7ae0\u77e5\u8bc6\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Python \u51fd\u6570\u4e4b\u95f4\u5982\u4f55\u5b9e\u73b0\u4ea4&#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-204827","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/204827","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=204827"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/204827\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=204827"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=204827"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=204827"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}