{"id":205065,"date":"2025-05-29T11:08:37","date_gmt":"2025-05-29T03:08:37","guid":{"rendered":"https:\/\/server.hk\/cnblog\/205065\/"},"modified":"2025-05-29T11:08:37","modified_gmt":"2025-05-29T03:08:37","slug":"python%e5%87%bd%e6%95%b0%e4%ba%a4%e4%ba%92%ef%bc%9a%e5%a6%82%e4%bd%95%e8%ae%a9%e4%b8%a4%e4%b8%aa%e5%87%bd%e6%95%b0%e7%9b%b8%e4%ba%92%e4%bd%9c%e7%94%a8%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/205065\/","title":{"rendered":"Python\u51fd\u6570\u4ea4\u4e92\uff1a\u5982\u4f55\u8ba9\u4e24\u4e2a\u51fd\u6570\u76f8\u4e92\u4f5c\u7528\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>Python\u51fd\u6570\u4ea4\u4e92\uff1a\u5982\u4f55\u8ba9\u4e24\u4e2a\u51fd\u6570\u76f8\u4e92\u4f5c\u7528\uff1f<\/h1>\n<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241122\/173227126967405ca56b47d.jpg\" class=\"aligncenter\"><\/p>\n<p><strong>\u51fd\u6570\u4ea4\u4e92\uff1a\u6587\u79d1\u5c0f\u767d\u7834\u89e3python\u51fd\u6570\u8c1c\u56e2<\/strong><\/p>\n<p>\u4f5c\u4e3a\u4e00\u540d\u6587\u79d1\u5c0f\u767d\uff0c\u4f60\u5728\u5b66\u4e60python\u51fd\u6570\u65f6\u53ef\u80fd\u4f1a\u9047\u5230\u4e00\u4e9b\u7591\u60d1\u3002\u6bd4\u5982\uff0c\u5982\u4f55\u8ba9\u4e24\u4e2a\u51fd\u6570\u76f8\u4e92\u4f5c\u7528\uff1f<\/p>\n<p><strong>\u95ee\u9898\uff1a\u51fd\u6570\u4ea4\u4e92\u7684\u56f0\u6270<\/strong><\/p>\n<p><strong>\u95ee\u9898\u5185\u5bb9\uff1a<\/strong><\/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>\u4e0a\u9762\u7684\u4ee3\u7801\u610f\u56fe\u5148\u901a\u8fc7 make_great \u51fd\u6570\u4fee\u6539\u5217\u8868 names\uff0c\u7136\u540e\u518d\u901a\u8fc7 show_magicians \u51fd\u6570\u663e\u793a\u4fee\u6539\u540e\u7684\u7ed3\u679c\u3002\u7136\u800c\uff0c\u5b9e\u9645\u8fd0\u884c\u65f6\uff0cshow_magicians \u51fd\u6570\u663e\u793a\u7684\u4ecd\u7136\u662f\u672a\u4fee\u6539\u7684 names\u3002<\/p>\n<p><strong>\u7591\u60d1\uff1a<\/strong><\/p>\n<p>\u4e24\u4e2a\u51fd\u6570\u662f\u5426\u53ef\u4ee5\u76f8\u4e92\u4f5c\u7528\uff1f<\/p>\n<p><strong>\u89e3\u51b3\uff1a\u51fd\u6570\u8fd4\u56de\u503c\u4e0e\u53c2\u6570\u4f20\u9012<\/strong><\/p>\n<p>\u8981\u8ba9\u4e24\u4e2a\u51fd\u6570\u76f8\u4e92\u4f5c\u7528\uff0c\u53ef\u4ee5\u5229\u7528python\u7684\u51fd\u6570\u8fd4\u56de\u503c\u4e0e\u53c2\u6570\u4f20\u9012\u7279\u6027\u3002<\/p>\n<p><strong>\u89e3\u7b54\uff1a<\/strong><\/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\u6539\u8fdb\u540e\u7684\u4ee3\u7801\u4e2d\uff0cmake_great \u51fd\u6570\u4f7f\u7528 map \u51fd\u6570\u8fd4\u56de\u4e86\u4e00\u4e2a\u53ef\u8fed\u4ee3\u5bf9\u8c61\u3002\u8be5\u5bf9\u8c61\u53ef\u4ee5\u88ab\u8d4b\u7ed9\u53d8\u91cf\u6216\u76f4\u63a5\u4f5c\u4e3a\u53c2\u6570\u4f20\u9012\u7ed9\u5176\u4ed6\u51fd\u6570\u3002<\/p>\n<p>show_magicians \u51fd\u6570\u4ee5 make_great \u8fd4\u56de\u7684\u53ef\u8fed\u4ee3\u5bf9\u8c61\u4e3a\u53c2\u6570\u3002\u8fd9\u610f\u5473\u7740 make_great \u6240\u505a\u7684\u4fee\u6539\u5c06\u53cd\u6620\u5728 show_magicians \u4e2d\u4f20\u5165\u7684\u53ef\u8fed\u4ee3\u5bf9\u8c61\u4e2d\uff0c\u4ece\u800c\u5b9e\u73b0\u51fd\u6570\u95f4\u7684\u4ea4\u4e92\u3002<\/p>\n<p>\u4eca\u5929\u5e26\u5927\u5bb6\u4e86\u89e3\u4e86\u7684\u76f8\u5173\u77e5\u8bc6\uff0c\u5e0c\u671b\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\uff1b\u5173\u4e8e\u6587\u7ae0\u7684\u6280\u672f\u77e5\u8bc6\u6211\u4eec\u4f1a\u4e00\u70b9\u70b9\u6df1\u5165\u4ecb\u7ecd\uff0c\u6b22\u8fce\u5927\u5bb6\u5173\u6ce8\u516c\u4f17\u53f7\uff0c\u4e00\u8d77\u5b66\u4e60\u7f16\u7a0b~<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Python\u51fd\u6570\u4ea4\u4e92\uff1a\u5982\u4f55\u8ba9\u4e24\u4e2a&#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-205065","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/205065","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=205065"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/205065\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=205065"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=205065"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=205065"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}