{"id":168482,"date":"2023-08-03T00:22:43","date_gmt":"2023-08-02T16:22:43","guid":{"rendered":"http:\/\/www.idc.net\/help\/168482\/"},"modified":"2023-08-03T00:22:43","modified_gmt":"2023-08-02T16:22:43","slug":"%e5%90%8e%e6%b5%aa%e4%ba%91python%e6%95%99%e7%a8%8b%ef%bc%9apython%e4%b8%ad%e7%9a%84%e9%80%92%e5%bd%92%e5%87%bd%e6%95%b0%e6%98%af%e4%bb%80%e4%b9%88","status":"publish","type":"post","link":"https:\/\/idc.net\/help\/168482\/","title":{"rendered":"\u540e\u6d6a\u4e91Python\u6559\u7a0b\uff1aPython\u4e2d\u7684\u9012\u5f52\u51fd\u6570\u662f\u4ec0\u4e48"},"content":{"rendered":"<p><strong><img decoding=\"async\" src=\"https:\/\/oss.py.cn\/pycn\/upload\/article\/000\/000\/003\/5d20011e54d2b105.jpg\" class=\"aligncenter\"><\/strong><\/p>\n<p><strong>Python \u9012\u5f52\u51fd\u6570<\/strong><\/p>\n<p>\u9012\u5f52\u7684\u7279\u6027\uff1a<\/p>\n<p>1.\u8c03\u7528\u81ea\u8eab\u51fd\u6570<\/p>\n<p>2.\u6709\u4e00\u4e2a\u7ed3\u675f\u6761\u4ef6<\/p>\n<p>3.\u9012\u5f52\u6548\u7387\u4e0d\u9ad8\uff0c\u53ef\u80fd\u4f1a\u5bfc\u81f4\u6808\u6ea2\u51fa(\u51fd\u6570\u8c03\u7528\u662f\u901a\u8fc7\u6808\u8fd9\u79cd\u6570\u636e\u7ed3\u6784\u5b9e\u73b0\u7684\uff0c\u6bcf\u8fdb\u5165\u4e00\u4e2a\u51fd\u6570\u8c03\u7528\uff0c\u6808\u5c31\u4f1a\u589e\u52a0\u4e00\u5c42\u6808\u5e27\uff0c\u51fd\u6570\u6bcf\u8fd4\u56de\uff0c\u6808\u5c31\u4f1a\u51cf\u5c11\u4e00\u5c42\u6808\u5e27\uff0c\u7531\u4e8e\u6808\u7684\u5927\u5c0f\u4e0d\u662f\u7684\uff0c\u9012\u5f52\u8c03\u7528\u8fc7\u591a\uff0c\u53ef\u80fd\u4f1a\u5bfc\u81f4\u6808\u6ea2\u51fa)<\/p>\n<p>\u76f8\u5173\u63a8\u8350\uff1a\u300aPython\u89c6\u9891\u6559\u7a0b\u300b<\/p>\n<pre>def&nbsp;f(n):\n&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;n&nbsp;==&nbsp;1:\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;1\n&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;n+f(n-1)\nprint(f(5))<\/pre>\n<p>\u8fd0\u884c\u7ed3\u679c:<\/p>\n<pre>15<\/pre>\n<p>\u6590\u6ce2\u90a3\u5951\u6570\u5217\uff1a1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ...<\/p>\n<p>\u8fd9\u4e2a\u6570\u5217\u4ece\u7b2c3\u9879\u5f00\u59cb\uff0c\u6bcf\u4e00\u9879\u90fd\u7b49\u4e8e\u524d\u4e24\u9879\u4e4b\u548c\u3002<\/p>\n<pre>def&nbsp;fibo(n):\n&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;n&nbsp;&lt;=&nbsp;1:\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;n\n&nbsp;&nbsp;&nbsp;&nbsp;return(fibo(n&nbsp;-&nbsp;1)&nbsp;+&nbsp;fibo(n&nbsp;-2))\nprint(fibo(5))<\/pre>\n<p>\u8fd0\u884c\u7ed3\u679c:<\/p>\n<pre>5<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Python \u9012\u5f52\u51fd\u6570 \u9012\u5f52\u7684\u7279\u6027\uff1a 1.\u8c03\u7528\u81ea\u8eab\u51fd\u6570 2.\u6709\u4e00\u4e2a\u7ed3\u675f\u6761\u4ef6 3.\u9012\u5f52\u6548\u7387\u4e0d\u9ad8\uff0c\u53ef\u80fd\u4f1a\u5bfc\u81f4\u6808\u6ea2\u51fa [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":168483,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[182397],"tags":[],"class_list":["post-168482","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python"],"_links":{"self":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/168482","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/comments?post=168482"}],"version-history":[{"count":0,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/168482\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media\/168483"}],"wp:attachment":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media?parent=168482"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/categories?post=168482"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/tags?post=168482"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}