{"id":720,"date":"2019-05-01T17:50:23","date_gmt":"2019-05-01T09:50:23","guid":{"rendered":"http:\/\/www.eait.co\/?p=720"},"modified":"2019-05-01T17:50:23","modified_gmt":"2019-05-01T09:50:23","slug":"%e5%87%bd%e6%95%b0%e4%bd%9c%e7%94%a8%e5%9f%9f%e5%92%8c%e5%8c%bf%e5%90%8d%e5%87%bd%e6%95%b0","status":"publish","type":"post","link":"https:\/\/notes.coremix.net\/?p=720","title":{"rendered":"\u51fd\u6570\u4f5c\u7528\u57df\u548c\u533f\u540d\u51fd\u6570"},"content":{"rendered":"<div>\u533f\u540d\u51fd\u6570<\/div>\n<div>filiter(lambda x: x&gt;10,li)<\/div>\n<div>lambda\u00a0\u53c2\u6570: \u8868\u8fbe\u5f0f<\/div>\n<div>\u533f\u540d\u51fd\u6570\u7684\u5e94\u7528\u573a\u666f<\/div>\n<div>\u7b80\u5355\u7684\u51fd\u6570\uff0c\u53ef\u4ee5\u4e0d\u4f7f\u7528def\u5b9a\u4e49\uff0c\u4f7f\u7528\u533f\u540d\u51fd\u6570\u5373\u53ef<\/div>\n<div>\u7c7b\u4f3c\u4e8efilter\u548cmap\u7b49\u51fd\u6570\u91cc\u9762\uff0c\u53ef\u4ee5\u4f7f\u7528\u533f\u540d\u51fd\u6570\u6765\u5904\u7406<\/div>\n<div>\u533f\u540d\u51fd\u6570\u7684\u5408\u7406\u4f7f\u7528\u53ef\u4ee5\u8ba9\u4ee3\u7801\u66f4\u7b80\u6d01<\/div>\n<div><\/div>\n<div>\u51fd\u6570\u4f5c\u7528\u57df<\/div>\n<div>\u5916\u90e8\u4e0d\u80fd\u8bbf\u95ee\u51fd\u6570\u5185\u90e8\u53d8\u91cf<\/div>\n<div>\u51fd\u6570\u5185\u90e8\u80fd\u591f\u8bbf\u95ee\u51fd\u6570\u5916\u90e8\u53d8\u91cf<\/div>\n<div>\u51fd\u6570\u91cc\u9762\u4e0d\u80fd\u4fee\u6539\u51fd\u6570\u5916\u90e8\u53d8\u91cf<\/div>\n<div>\u51fd\u6570\u91cc\u9762\u548c\u51fd\u6570\u5916\u9762\u53d8\u91cf\u540d\u76f8\u540c<\/div>\n<div><\/div>\n<div>global\u5168\u5c40\u53d8\u91cf<\/div>\n<div>x = 1<\/div>\n<div>def fun1():<\/div>\n<div>\u00a0 \u00a0 global x<\/div>\n<div>\u00a0 \u00a0 x = x+1<\/div>\n<div>\u00a0 \u00a0 rutrun x<\/div>\n<div><\/div>\n<div>nonlocal(\u5c40\u90e8\u53d8\u91cf)<\/div>\n<div>def fun2():<\/div>\n<div>\u00a0 \u00a0 a = 1<\/div>\n<div>\u00a0 \u00a0 def fun3():<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 nonlacal a<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 a = a+1<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 return a<\/div>\n<div>\u00a0 \u00a0 return fun3()<\/div>\n<div><\/div>\n<div>\u51fd\u6570\u4f5c\u7528\u57df<\/div>\n<div>\u51fd\u6570\u5185\u90e8\uff1a\u51fd\u6570\u5185\u90e8\u7684\u53d8\u91cf\uff0c\u4f5c\u7528\u57df\u53ea\u5728\u51fd\u6570\u5185\u90e8\uff0c\u51fd\u6570\u5185\u90e8\u4e0d\u80fd\u76f4\u63a5\u4fee\u6539\u51fd\u6570\u5916\u90e8\u7684\u53d8\u91cf\u3002<\/div>\n<div>global\uff1a\u51fd\u6570\u5185\u90e8\u5982\u679c\u9700\u8981\u66f4\u6539\u5168\u5c40\u53d8\u91cf\uff0c\u5c31\u9700\u8981\u4f7f\u7528global\u4fee\u9970\u53d8\u91cf<\/div>\n<div>nonlocal\uff1a\u5728\u51fd\u6570\u5d4c\u5957\u51fd\u6570\u7684\u60c5\u51b5\u4e0b\uff0c\u540c\u6837\u4e5f\u6709\u51fd\u6570\u4f5c\u7528\u57df\u95ee\u9898\uff0c\u4f46\u662fpython3\u4e2d\u63d0\u4f9b\u4e86\u65b9\u4fbf\uff0c\u53ea\u9700\u8981\u4f7f\u7528nonlocal\u5c31\u53ef\u4ee5\u5728\u91cc\u5c42\u51fd\u6570\u7684\u5185\u90e8\u4fee\u6539\u5916\u5c42\u51fd\u6570\u53d8\u91cf<\/div>\n<div><\/div>\n<div>\u95ed\u5305<\/div>\n<div>\u95ed\u5305\u662f\u51fd\u6570\u91cc\u9762\u5d4c\u5957\u51fd\u6570\uff0c\u5916\u5c42\u51fd\u6570\u8fd4\u56de\u91cc\u5c42\u51fd\u6570\uff0c\u8fd9\u79cd\u60c5\u51b5\u79f0\u4e4b\u4e3a\u95ed\u5305<\/div>\n<div>\u95ed\u5305\u662f\u6982\u5ff5\uff0c\u4e0d\u662f\u67d0\u79cd\u51fd\u6570\u7c7b\u578b\uff0c\u548c\u9012\u5f52\u7684\u6982\u5ff5\u7c7b\u4f3c\uff0c\u5c31\u662f\u79cd\u7279\u6b8a\u7684\u51fd\u6570\u8c03\u7528<\/div>\n<div>\u95ed\u5305\u53ef\u4ee5\u5f97\u5230\u5916\u5c42\u51fd\u6570\u7684\u5c40\u90e8\u53d8\u91cf\uff0c\u662f\u51fd\u6570\u5185\u90e8\u548c\u51fd\u6570\u5916\u90e8\u6c9f\u901a\u7684\u6865\u6881<\/div>\n<div>.<\/div>\n<div>\u9012\u5f52<\/div>\n<div>def fun(n):<\/div>\n<div>\u00a0 \u00a0 if n ==1:<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 return 1<\/div>\n<div>\u00a0 \u00a0 return fun(n-1)*n<\/div>\n<div><\/div>\n<div><\/div>\n<div>\u56de\u8c03\uff1a<\/div>\n<div>def back(fu,n):<\/div>\n<div>\u00a0 \u00a0 if n:<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 fu()<\/div>\n<div>\u00a0 \u00a0 else:<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 print(&#8216;xx&#8217;)<\/div>\n<div><\/div>\n<div>def fu():<\/div>\n<div>\u00a0 \u00a0 print(&#8216;huidiao&#8217;)<\/div>\n<div><\/div>\n<div>back(fu,n)<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u533f\u540d\u51fd\u6570 filiter(lambda x: x&gt;10,li) lambda\u00a0\u53c2\u6570: \u8868\u8fbe\u5f0f \u533f\u540d\u51fd\u6570\u7684 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[20],"class_list":["post-720","post","type-post","status-publish","format-standard","hentry","category-python_note","tag-python"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/posts\/720","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=720"}],"version-history":[{"count":1,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/posts\/720\/revisions"}],"predecessor-version":[{"id":721,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/posts\/720\/revisions\/721"}],"wp:attachment":[{"href":"https:\/\/notes.coremix.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=720"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=720"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=720"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}