{"id":1572,"date":"2023-02-06T22:55:57","date_gmt":"2023-02-06T14:55:57","guid":{"rendered":"http:\/\/zhang.mba\/?p=1572"},"modified":"2023-02-06T22:57:24","modified_gmt":"2023-02-06T14:57:24","slug":"python-qian-tao-han-shu","status":"publish","type":"post","link":"https:\/\/zhang.mba\/index.php\/2023\/02\/06\/22\/55\/57\/1572\/python-qian-tao-han-shu\/python\/zhangzhiqi\/","title":{"rendered":"Python \u5d4c\u5957\u51fd\u6570"},"content":{"rendered":"<p>\u5728 Python \u4e2d\uff0c\u51fd\u6570\u53ef\u4ee5\u4f5c\u4e3a\u53e6\u4e00\u4e2a\u51fd\u6570\u7684\u53c2\u6570\uff0c\u88ab\u79f0\u4e3a\u5d4c\u5957\u51fd\u6570\uff08Nested Functions\uff09\u3002<\/p>\n<p>\u5d4c\u5957\u51fd\u6570\u662f\u4e00\u4e2a\u5728\u53e6\u4e00\u4e2a\u51fd\u6570\u5185\u5b9a\u4e49\u7684\u51fd\u6570\uff0c\u5b83\u53ef\u4ee5\u8bbf\u95ee\u5916\u90e8\u51fd\u6570\u7684\u6240\u6709\u53d8\u91cf\uff0c\u4e5f\u53ef\u4ee5\u88ab\u5916\u90e8\u51fd\u6570\u8c03\u7528\u3002<\/p>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff1a<\/p>\n<pre><code class=\"language-python\">def outer_function(x):\n    def inner_function(y):\n        return x + y\n    return inner_function\n\nresult = outer_function(10)\nprint(result(20))\n<\/code><\/pre>\n<p>\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0c<code>outer_function<\/code> \u51fd\u6570\u8fd4\u56de\u4e86 <code>inner_function<\/code> \u51fd\u6570\u3002\u56e0\u6b64\uff0c\u5f53\u6211\u4eec\u8c03\u7528 <code>outer_function(10)<\/code> \u65f6\uff0c\u5b83\u8fd4\u56de\u4e86 <code>inner_function<\/code> \u51fd\u6570\u7684\u5f15\u7528\u3002\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u8c03\u7528 <code>result(20)<\/code> \u6765\u8bbf\u95ee\u8be5\u51fd\u6570\uff0c\u5b83\u5c06\u8fd4\u56de <code>30<\/code>\u3002<\/p>\n<p>\u5d4c\u5957\u51fd\u6570\u662f\u4e00\u79cd\u9ad8\u7ea7\u7684\u7f16\u7a0b\u6280\u5de7\uff0c\u53ef\u4ee5\u5e2e\u52a9\u60a8\u5b9e\u73b0\u66f4\u590d\u6742\u7684\u4ee3\u7801\u7ed3\u6784\u3002\u4f46\u662f\uff0c\u8bf7\u5c0f\u5fc3\u4f7f\u7528\u5b83\u4eec\uff0c\u56e0\u4e3a\u5b83\u4eec\u53ef\u80fd\u5bfc\u81f4\u4ee3\u7801\u53d8\u5f97\u66f4\u96be\u9605<\/p>\n<!--CusAds0-->\n<div style=\"font-size: 0px; height: 0px; line-height: 0px; margin: 0; padding: 0; clear: both;\"><\/div>","protected":false},"excerpt":{"rendered":"<p>\u5728 Python \u4e2d\uff0c\u51fd\u6570\u53ef\u4ee5\u4f5c\u4e3a\u53e6\u4e00\u4e2a\u51fd\u6570\u7684\u53c2\u6570\uff0c\u88ab\u79f0\u4e3a\u5d4c\u5957\u51fd\u6570\uff08Nested Functions\uff09\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0},"categories":[12],"tags":[],"_links":{"self":[{"href":"https:\/\/zhang.mba\/index.php\/wp-json\/wp\/v2\/posts\/1572"}],"collection":[{"href":"https:\/\/zhang.mba\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zhang.mba\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zhang.mba\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zhang.mba\/index.php\/wp-json\/wp\/v2\/comments?post=1572"}],"version-history":[{"count":0,"href":"https:\/\/zhang.mba\/index.php\/wp-json\/wp\/v2\/posts\/1572\/revisions"}],"wp:attachment":[{"href":"https:\/\/zhang.mba\/index.php\/wp-json\/wp\/v2\/media?parent=1572"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zhang.mba\/index.php\/wp-json\/wp\/v2\/categories?post=1572"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zhang.mba\/index.php\/wp-json\/wp\/v2\/tags?post=1572"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}