{"id":1167756,"date":"2025-01-15T15:49:18","date_gmt":"2025-01-15T07:49:18","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1167756.html"},"modified":"2025-01-15T15:49:22","modified_gmt":"2025-01-15T07:49:22","slug":"python%e4%b8%ad%e5%a6%82%e4%bd%95%e6%b7%bb%e5%8a%a0%e8%be%93%e5%87%ba%e6%9d%a1%e4%bb%b6","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1167756.html","title":{"rendered":"python\u4e2d\u5982\u4f55\u6dfb\u52a0\u8f93\u51fa\u6761\u4ef6"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/26065153\/a8939a26-54ea-4fdf-bbea-51351d766771.webp\" alt=\"python\u4e2d\u5982\u4f55\u6dfb\u52a0\u8f93\u51fa\u6761\u4ef6\" \/><\/p>\n<p><p> <strong>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528\u6761\u4ef6\u8bed\u53e5\uff08\u5982if\u8bed\u53e5\uff09\u3001\u5faa\u73af\u3001\u51fd\u6570\u548c\u5176\u4ed6\u7f16\u7a0b\u7ed3\u6784\u6765\u6dfb\u52a0\u8f93\u51fa\u6761\u4ef6\u3002<\/strong> \u4f8b\u5982\uff0c\u53ef\u4ee5\u4f7f\u7528if\u8bed\u53e5\u6765\u68c0\u67e5\u7279\u5b9a\u6761\u4ef6\u662f\u5426\u4e3a\u771f\uff0c\u5e76\u4e14\u53ea\u6709\u5728\u6ee1\u8db3\u6761\u4ef6\u65f6\u624d\u8f93\u51fa\u4fe1\u606f\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">number = 10<\/p>\n<p>if number &gt; 5:<\/p>\n<p>    print(&quot;Number is greater than 5&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>\u8be6\u7ec6\u63cf\u8ff0\uff1a<\/strong> \u4ee5\u4e0a\u4ee3\u7801\u4e2d\uff0c\u53d8\u91cf<code>number<\/code>\u7684\u503c\u4e3a10\uff0c\u6761\u4ef6<code>number &gt; 5<\/code>\u4e3a\u771f\uff0c\u56e0\u6b64\u4f1a\u8f93\u51fa&quot;Number is greater than 5&quot;\u3002\u5982\u679c\u6761\u4ef6\u4e3a\u5047\uff0c\u5219\u4e0d\u4f1a\u6709\u4efb\u4f55\u8f93\u51fa\u3002\u8fd9\u79cd\u65b9\u5f0f\u975e\u5e38\u6709\u7528\uff0c\u53ef\u4ee5\u7528\u4e8e\u5404\u79cd\u60c5\u51b5\uff0c\u4f8b\u5982\u8fc7\u6ee4\u6570\u636e\u3001\u5904\u7406\u8f93\u5165\u9a8c\u8bc1\u3001\u5728\u7279\u5b9a\u6761\u4ef6\u4e0b\u6267\u884c\u64cd\u4f5c\u7b49\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u4f7f\u7528\u6761\u4ef6\u8bed\u53e5<\/h3>\n<\/p>\n<p><h4>1\u3001\u57fa\u672cif\u8bed\u53e5<\/h4>\n<\/p>\n<p><p>\u5728Python\u4e2d\uff0c<code>if<\/code>\u8bed\u53e5\u662f\u6700\u57fa\u672c\u7684\u6761\u4ef6\u8bed\u53e5\uff0c\u7528\u4e8e\u68c0\u67e5\u67d0\u4e2a\u6761\u4ef6\u662f\u5426\u4e3a\u771f\u3002\u5982\u679c\u6761\u4ef6\u4e3a\u771f\uff0c\u5219\u6267\u884c\u76f8\u5e94\u7684\u4ee3\u7801\u5757\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">temperature = 30<\/p>\n<p>if temperature &gt; 25:<\/p>\n<p>    print(&quot;It&#39;s a hot day&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c<code>temperature<\/code>\u7684\u503c\u4e3a30\uff0c\u6ee1\u8db3\u6761\u4ef6<code>temperature &gt; 25<\/code>\uff0c\u56e0\u6b64\u8f93\u51fa &quot;It&#39;s a hot day&quot;\u3002<\/p>\n<\/p>\n<p><h4>2\u3001if-else\u8bed\u53e5<\/h4>\n<\/p>\n<p><p><code>if-else<\/code>\u8bed\u53e5\u7528\u4e8e\u5728\u6761\u4ef6\u4e0d\u6ee1\u8db3\u65f6\u6267\u884c\u53e6\u4e00\u6bb5\u4ee3\u7801\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">temperature = 20<\/p>\n<p>if temperature &gt; 25:<\/p>\n<p>    print(&quot;It&#39;s a hot day&quot;)<\/p>\n<p>else:<\/p>\n<p>    print(&quot;It&#39;s not a hot day&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>temperature<\/code>\u7684\u503c\u4e3a20\uff0c\u4e0d\u6ee1\u8db3\u6761\u4ef6<code>temperature &gt; 25<\/code>\uff0c\u56e0\u6b64\u8f93\u51fa &quot;It&#39;s not a hot day&quot;\u3002<\/p>\n<\/p>\n<p><h4>3\u3001if-elif-else\u8bed\u53e5<\/h4>\n<\/p>\n<p><p>\u5f53\u6709\u591a\u4e2a\u6761\u4ef6\u9700\u8981\u68c0\u67e5\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528<code>if-elif-else<\/code>\u7ed3\u6784\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">temperature = 20<\/p>\n<p>if temperature &gt; 30:<\/p>\n<p>    print(&quot;It&#39;s a very hot day&quot;)<\/p>\n<p>elif temperature &gt; 25:<\/p>\n<p>    print(&quot;It&#39;s a hot day&quot;)<\/p>\n<p>else:<\/p>\n<p>    print(&quot;It&#39;s not a hot day&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>temperature<\/code>\u7684\u503c\u4e3a20\uff0c\u4e0d\u6ee1\u8db3\u524d\u4e24\u4e2a\u6761\u4ef6\uff0c\u56e0\u6b64\u8f93\u51fa &quot;It&#39;s not a hot day&quot;\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u4f7f\u7528\u903b\u8f91\u8fd0\u7b97\u7b26<\/h3>\n<\/p>\n<p><p>\u903b\u8f91\u8fd0\u7b97\u7b26\uff08\u5982<code>and<\/code>\u3001<code>or<\/code>\u3001<code>not<\/code>\uff09\u53ef\u4ee5\u7528\u4e8e\u7ec4\u5408\u591a\u4e2a\u6761\u4ef6\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u4f7f\u7528and\u8fd0\u7b97\u7b26<\/h4>\n<\/p>\n<p><p><code>and<\/code>\u8fd0\u7b97\u7b26\u7528\u4e8e\u68c0\u67e5\u4e24\u4e2a\u6761\u4ef6\u90fd\u4e3a\u771f\u65f6\u7684\u60c5\u51b5\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">temperature = 27<\/p>\n<p>humidity = 70<\/p>\n<p>if temperature &gt; 25 and humidity &gt; 65:<\/p>\n<p>    print(&quot;It&#39;s hot and humid&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u4e24\u4e2a\u6761\u4ef6\u90fd\u6ee1\u8db3\uff0c\u56e0\u6b64\u8f93\u51fa &quot;It&#39;s hot and humid&quot;\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u4f7f\u7528or\u8fd0\u7b97\u7b26<\/h4>\n<\/p>\n<p><p><code>or<\/code>\u8fd0\u7b97\u7b26\u7528\u4e8e\u68c0\u67e5\u4efb\u4e00\u6761\u4ef6\u4e3a\u771f\u65f6\u7684\u60c5\u51b5\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">temperature = 27<\/p>\n<p>humidity = 50<\/p>\n<p>if temperature &gt; 25 or humidity &gt; 65:<\/p>\n<p>    print(&quot;It&#39;s either hot or humid&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6ee1\u8db3\u7b2c\u4e00\u4e2a\u6761\u4ef6\uff0c\u56e0\u6b64\u8f93\u51fa &quot;It&#39;s either hot or humid&quot;\u3002<\/p>\n<\/p>\n<p><h4>3\u3001\u4f7f\u7528not\u8fd0\u7b97\u7b26<\/h4>\n<\/p>\n<p><p><code>not<\/code>\u8fd0\u7b97\u7b26\u7528\u4e8e\u53d6\u53cd\u4e00\u4e2a\u6761\u4ef6\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">is_r<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>ning = False<\/p>\n<p>if not is_raining:<\/p>\n<p>    print(&quot;It&#39;s not raining&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>is_raining<\/code>\u4e3a<code>False<\/code>\uff0c\u56e0\u6b64\u6761\u4ef6<code>not is_raining<\/code>\u4e3a\u771f\uff0c\u8f93\u51fa &quot;It&#39;s not raining&quot;\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u4f7f\u7528\u5faa\u73af\u548c\u6761\u4ef6<\/h3>\n<\/p>\n<p><p>\u5faa\u73af\uff08\u5982<code>for<\/code>\u548c<code>while<\/code>\uff09\u53ef\u4ee5\u4e0e\u6761\u4ef6\u8bed\u53e5\u7ed3\u5408\u4f7f\u7528\uff0c\u4ee5\u4fbf\u5728\u6ee1\u8db3\u7279\u5b9a\u6761\u4ef6\u65f6\u63a7\u5236\u5faa\u73af\u7684\u6267\u884c\u3002<\/p>\n<\/p>\n<p><h4>1\u3001for\u5faa\u73af\u4e0e\u6761\u4ef6<\/h4>\n<\/p>\n<p><p>\u5728<code>for<\/code>\u5faa\u73af\u4e2d\u53ef\u4ee5\u4f7f\u7528<code>if<\/code>\u8bed\u53e5\u6765\u68c0\u67e5\u6bcf\u6b21\u8fed\u4ee3\u4e2d\u7684\u6761\u4ef6\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]<\/p>\n<p>for number in numbers:<\/p>\n<p>    if number % 2 == 0:<\/p>\n<p>        print(f&quot;{number} is even&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u5faa\u73af\u904d\u5386\u5217\u8868\u4e2d\u7684\u6bcf\u4e2a\u6570\u5b57\uff0c\u5e76\u4f7f\u7528<code>if<\/code>\u8bed\u53e5\u68c0\u67e5\u6570\u5b57\u662f\u5426\u4e3a\u5076\u6570\u3002\u5982\u679c\u662f\u5076\u6570\uff0c\u5219\u8f93\u51fa\u8be5\u6570\u5b57\u3002<\/p>\n<\/p>\n<p><h4>2\u3001while\u5faa\u73af\u4e0e\u6761\u4ef6<\/h4>\n<\/p>\n<p><p>\u5728<code>while<\/code>\u5faa\u73af\u4e2d\u53ef\u4ee5\u4f7f\u7528<code>if<\/code>\u8bed\u53e5\u6765\u68c0\u67e5\u6bcf\u6b21\u8fed\u4ee3\u4e2d\u7684\u6761\u4ef6\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">count = 0<\/p>\n<p>while count &lt; 10:<\/p>\n<p>    count += 1<\/p>\n<p>    if count % 2 == 0:<\/p>\n<p>        print(f&quot;{count} is even&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>while<\/code>\u5faa\u73af\u5728<code>count<\/code>\u5c0f\u4e8e10\u65f6\u7ee7\u7eed\u6267\u884c\uff0c\u6bcf\u6b21\u8fed\u4ee3\u4e2d<code>count<\/code>\u589e\u52a01\uff0c\u5e76\u4f7f\u7528<code>if<\/code>\u8bed\u53e5\u68c0\u67e5<code>count<\/code>\u662f\u5426\u4e3a\u5076\u6570\u3002\u5982\u679c\u662f\u5076\u6570\uff0c\u5219\u8f93\u51fa\u8be5\u6570\u5b57\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u4f7f\u7528\u51fd\u6570\u548c\u6761\u4ef6<\/h3>\n<\/p>\n<p><p>\u5b9a\u4e49\u51fd\u6570\u65f6\uff0c\u53ef\u4ee5\u5728\u51fd\u6570\u5185\u90e8\u4f7f\u7528\u6761\u4ef6\u8bed\u53e5\u6765\u63a7\u5236\u51fd\u6570\u7684\u884c\u4e3a\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u51fd\u6570\u4e0eif\u8bed\u53e5<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u5728\u51fd\u6570\u4e2d\u4f7f\u7528<code>if<\/code>\u8bed\u53e5\u6765\u68c0\u67e5\u53c2\u6570\u7684\u503c\u5e76\u51b3\u5b9a\u8fd4\u56de\u7684\u7ed3\u679c\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def check_temperature(temp):<\/p>\n<p>    if temp &gt; 30:<\/p>\n<p>        return &quot;It&#39;s a very hot day&quot;<\/p>\n<p>    elif temp &gt; 25:<\/p>\n<p>        return &quot;It&#39;s a hot day&quot;<\/p>\n<p>    else:<\/p>\n<p>        return &quot;It&#39;s not a hot day&quot;<\/p>\n<p>print(check_temperature(27))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u5b9a\u4e49\u4e86\u4e00\u4e2a\u540d\u4e3a<code>check_temperature<\/code>\u7684\u51fd\u6570\uff0c\u8be5\u51fd\u6570\u6839\u636e\u4f20\u5165\u7684\u53c2\u6570<code>temp<\/code>\u7684\u503c\u8fd4\u56de\u4e0d\u540c\u7684\u5b57\u7b26\u4e32\u3002\u8c03\u7528<code>check_temperature(27)<\/code>\u65f6\uff0c\u8f93\u51fa &quot;It&#39;s a hot day&quot;\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u51fd\u6570\u4e0e\u903b\u8f91\u8fd0\u7b97\u7b26<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u5728\u51fd\u6570\u4e2d\u4f7f\u7528\u903b\u8f91\u8fd0\u7b97\u7b26\u6765\u7ec4\u5408\u591a\u4e2a\u6761\u4ef6\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def is_comfortable(temp, humidity):<\/p>\n<p>    if temp &gt; 20 and temp &lt; 25 and humidity &lt; 60:<\/p>\n<p>        return True<\/p>\n<p>    else:<\/p>\n<p>        return False<\/p>\n<p>print(is_comfortable(22, 55))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u5b9a\u4e49\u4e86\u4e00\u4e2a\u540d\u4e3a<code>is_comfortable<\/code>\u7684\u51fd\u6570\uff0c\u8be5\u51fd\u6570\u6839\u636e\u4f20\u5165\u7684\u6e29\u5ea6\u548c\u6e7f\u5ea6\u53c2\u6570\u8fd4\u56de\u5e03\u5c14\u503c\u3002\u8c03\u7528<code>is_comfortable(22, 55)<\/code>\u65f6\uff0c\u8f93\u51fa<code>True<\/code>\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001\u4f7f\u7528\u5217\u8868\u63a8\u5bfc\u5f0f\u548c\u6761\u4ef6<\/h3>\n<\/p>\n<p><p>\u5217\u8868\u63a8\u5bfc\u5f0f\u662f\u4e00\u79cd\u7b80\u6d01\u7684\u521b\u5efa\u5217\u8868\u7684\u65b9\u5f0f\uff0c\u53ef\u4ee5\u5728\u5176\u4e2d\u4f7f\u7528\u6761\u4ef6\u8bed\u53e5\u6765\u8fc7\u6ee4\u6570\u636e\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u57fa\u672c\u5217\u8868\u63a8\u5bfc\u5f0f<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u4f7f\u7528\u5217\u8868\u63a8\u5bfc\u5f0f\u6765\u751f\u6210\u6ee1\u8db3\u7279\u5b9a\u6761\u4ef6\u7684\u5217\u8868\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]<\/p>\n<p>even_numbers = [number for number in numbers if number % 2 == 0]<\/p>\n<p>print(even_numbers)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u5217\u8868\u63a8\u5bfc\u5f0f\u751f\u6210\u4e00\u4e2a\u53ea\u5305\u542b\u5076\u6570\u7684\u5217\u8868\uff0c\u8f93\u51fa<code>[2, 4, 6, 8, 10]<\/code>\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u5d4c\u5957\u5217\u8868\u63a8\u5bfc\u5f0f<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u5728\u5217\u8868\u63a8\u5bfc\u5f0f\u4e2d\u5d4c\u5957\u591a\u4e2a\u6761\u4ef6\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]<\/p>\n<p>flattened_even_numbers = [num for row in matrix for num in row if num % 2 == 0]<\/p>\n<p>print(flattened_even_numbers)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u5d4c\u5957\u5217\u8868\u63a8\u5bfc\u5f0f\u751f\u6210\u4e00\u4e2a\u5305\u542b\u6240\u6709\u5076\u6570\u7684\u6241\u5e73\u5217\u8868\uff0c\u8f93\u51fa<code>[2, 4, 6, 8]<\/code>\u3002<\/p>\n<\/p>\n<p><h3>\u516d\u3001\u4f7f\u7528\u5b57\u5178\u63a8\u5bfc\u5f0f\u548c\u6761\u4ef6<\/h3>\n<\/p>\n<p><p>\u5b57\u5178\u63a8\u5bfc\u5f0f\u7c7b\u4f3c\u4e8e\u5217\u8868\u63a8\u5bfc\u5f0f\uff0c\u4f46\u7528\u4e8e\u751f\u6210\u5b57\u5178\uff0c\u53ef\u4ee5\u5728\u5176\u4e2d\u4f7f\u7528\u6761\u4ef6\u8bed\u53e5\u6765\u8fc7\u6ee4\u6570\u636e\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u57fa\u672c\u5b57\u5178\u63a8\u5bfc\u5f0f<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u4f7f\u7528\u5b57\u5178\u63a8\u5bfc\u5f0f\u6765\u751f\u6210\u6ee1\u8db3\u7279\u5b9a\u6761\u4ef6\u7684\u5b57\u5178\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]<\/p>\n<p>even_squares = {number: number2 for number in numbers if number % 2 == 0}<\/p>\n<p>print(even_squares)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u5b57\u5178\u63a8\u5bfc\u5f0f\u751f\u6210\u4e00\u4e2a\u952e\u4e3a\u5076\u6570\uff0c\u503c\u4e3a\u5176\u5e73\u65b9\u7684\u5b57\u5178\uff0c\u8f93\u51fa <code>{2: 4, 4: 16, 6: 36, 8: 64, 10: 100}<\/code>\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u5d4c\u5957\u5b57\u5178\u63a8\u5bfc\u5f0f<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u5728\u5b57\u5178\u63a8\u5bfc\u5f0f\u4e2d\u5d4c\u5957\u591a\u4e2a\u6761\u4ef6\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]<\/p>\n<p>even_squares = {num: num2 for row in matrix for num in row if num % 2 == 0}<\/p>\n<p>print(even_squares)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u5d4c\u5957\u5b57\u5178\u63a8\u5bfc\u5f0f\u751f\u6210\u4e00\u4e2a\u952e\u4e3a\u5076\u6570\uff0c\u503c\u4e3a\u5176\u5e73\u65b9\u7684\u5b57\u5178\uff0c\u8f93\u51fa <code>{2: 4, 4: 16, 6: 36, 8: 64}<\/code>\u3002<\/p>\n<\/p>\n<p><h3>\u4e03\u3001\u4f7f\u7528\u5f02\u5e38\u5904\u7406\u548c\u6761\u4ef6<\/h3>\n<\/p>\n<p><p>\u5f02\u5e38\u5904\u7406\u7528\u4e8e\u5904\u7406\u7a0b\u5e8f\u8fd0\u884c\u65f6\u53ef\u80fd\u53d1\u751f\u7684\u9519\u8bef\uff0c\u53ef\u4ee5\u5728\u5f02\u5e38\u5904\u7406\u4ee3\u7801\u4e2d\u4f7f\u7528\u6761\u4ef6\u8bed\u53e5\u3002<\/p>\n<\/p>\n<p><h4>1\u3001try-except\u8bed\u53e5<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u5728<code>try<\/code>\u5757\u4e2d\u6267\u884c\u4ee3\u7801\uff0c\u5e76\u5728<code>except<\/code>\u5757\u4e2d\u5904\u7406\u5f02\u5e38\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">try:<\/p>\n<p>    result = 10 \/ 0<\/p>\n<p>except ZeroDivisionError:<\/p>\n<p>    print(&quot;Cannot divide by zero&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u5c1d\u8bd5\u9664\u4ee5\u96f6\u4f1a\u5f15\u53d1<code>ZeroDivisionError<\/code>\uff0c\u56e0\u6b64\u8f93\u51fa &quot;Cannot divide by zero&quot;\u3002<\/p>\n<\/p>\n<p><h4>2\u3001try-except-else\u8bed\u53e5<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u5728<code>try<\/code>\u5757\u4e2d\u6267\u884c\u4ee3\u7801\uff0c\u5e76\u5728\u6ca1\u6709\u5f02\u5e38\u65f6\u6267\u884c<code>else<\/code>\u5757\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">try:<\/p>\n<p>    result = 10 \/ 2<\/p>\n<p>except ZeroDivisionError:<\/p>\n<p>    print(&quot;Cannot divide by zero&quot;)<\/p>\n<p>else:<\/p>\n<p>    print(&quot;Division successful&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u9664\u6cd5\u64cd\u4f5c\u6210\u529f\uff0c\u6ca1\u6709\u5f15\u53d1\u5f02\u5e38\uff0c\u56e0\u6b64\u8f93\u51fa &quot;Division successful&quot;\u3002<\/p>\n<\/p>\n<p><h4>3\u3001try-except-finally\u8bed\u53e5<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u5728<code>try<\/code>\u5757\u4e2d\u6267\u884c\u4ee3\u7801\uff0c\u5e76\u65e0\u8bba\u662f\u5426\u53d1\u751f\u5f02\u5e38\uff0c\u90fd\u5728<code>finally<\/code>\u5757\u4e2d\u6267\u884c\u4ee3\u7801\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">try:<\/p>\n<p>    result = 10 \/ 2<\/p>\n<p>except ZeroDivisionError:<\/p>\n<p>    print(&quot;Cannot divide by zero&quot;)<\/p>\n<p>finally:<\/p>\n<p>    print(&quot;Execution complete&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u65e0\u8bba\u662f\u5426\u5f15\u53d1\u5f02\u5e38\uff0c\u90fd\u4f1a\u8f93\u51fa &quot;Execution complete&quot;\u3002<\/p>\n<\/p>\n<p><h3>\u516b\u3001\u4f7f\u7528\u7c7b\u548c\u5bf9\u8c61\u4e0e\u6761\u4ef6<\/h3>\n<\/p>\n<p><p>\u5728\u9762\u5411\u5bf9\u8c61\u7f16\u7a0b\u4e2d\uff0c\u53ef\u4ee5\u5728\u7c7b\u7684\u65b9\u6cd5\u4e2d\u4f7f\u7528\u6761\u4ef6\u8bed\u53e5\u6765\u63a7\u5236\u5bf9\u8c61\u7684\u884c\u4e3a\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u7c7b\u4e0eif\u8bed\u53e5<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u5728\u7c7b\u7684\u65b9\u6cd5\u4e2d\u4f7f\u7528<code>if<\/code>\u8bed\u53e5\u6765\u68c0\u67e5\u5c5e\u6027\u7684\u503c\u5e76\u51b3\u5b9a\u8fd4\u56de\u7684\u7ed3\u679c\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">class Temperature:<\/p>\n<p>    def __init__(self, temp):<\/p>\n<p>        self.temp = temp<\/p>\n<p>    def check_temp(self):<\/p>\n<p>        if self.temp &gt; 30:<\/p>\n<p>            return &quot;It&#39;s a very hot day&quot;<\/p>\n<p>        elif self.temp &gt; 25:<\/p>\n<p>            return &quot;It&#39;s a hot day&quot;<\/p>\n<p>        else:<\/p>\n<p>            return &quot;It&#39;s not a hot day&quot;<\/p>\n<p>temp = Temperature(27)<\/p>\n<p>print(temp.check_temp())<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u5b9a\u4e49\u4e86\u4e00\u4e2a<code>Temperature<\/code>\u7c7b\uff0c\u5e76\u5728<code>check_temp<\/code>\u65b9\u6cd5\u4e2d\u4f7f\u7528\u6761\u4ef6\u8bed\u53e5\u6765\u68c0\u67e5\u6e29\u5ea6\u503c\u3002\u8c03\u7528<code>check_temp<\/code>\u65b9\u6cd5\u65f6\uff0c\u8f93\u51fa &quot;It&#39;s a hot day&quot;\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u7c7b\u4e0e\u903b\u8f91\u8fd0\u7b97\u7b26<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u5728\u7c7b\u7684\u65b9\u6cd5\u4e2d\u4f7f\u7528\u903b\u8f91\u8fd0\u7b97\u7b26\u6765\u7ec4\u5408\u591a\u4e2a\u6761\u4ef6\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">class Comfort:<\/p>\n<p>    def __init__(self, temp, humidity):<\/p>\n<p>        self.temp = temp<\/p>\n<p>        self.humidity = humidity<\/p>\n<p>    def is_comfortable(self):<\/p>\n<p>        if self.temp &gt; 20 and self.temp &lt; 25 and self.humidity &lt; 60:<\/p>\n<p>            return True<\/p>\n<p>        else:<\/p>\n<p>            return False<\/p>\n<p>comfort = Comfort(22, 55)<\/p>\n<p>print(comfort.is_comfortable())<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u5b9a\u4e49\u4e86\u4e00\u4e2a<code>Comfort<\/code>\u7c7b\uff0c\u5e76\u5728<code>is_comfortable<\/code>\u65b9\u6cd5\u4e2d\u4f7f\u7528\u903b\u8f91\u8fd0\u7b97\u7b26\u6765\u7ec4\u5408\u591a\u4e2a\u6761\u4ef6\u3002\u8c03\u7528<code>is_comfortable<\/code>\u65b9\u6cd5\u65f6\uff0c\u8f93\u51fa<code>True<\/code>\u3002<\/p>\n<\/p>\n<p><h3>\u4e5d\u3001\u4f7f\u7528\u751f\u6210\u5668\u548c\u6761\u4ef6<\/h3>\n<\/p>\n<p><p>\u751f\u6210\u5668\u662f\u4e00\u79cd\u7279\u6b8a\u7684\u8fed\u4ee3\u5668\uff0c\u53ef\u4ee5\u5728\u751f\u6210\u5668\u51fd\u6570\u4e2d\u4f7f\u7528\u6761\u4ef6\u8bed\u53e5\u6765\u63a7\u5236\u751f\u6210\u7684\u503c\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u57fa\u672c\u751f\u6210\u5668<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u5728\u751f\u6210\u5668\u51fd\u6570\u4e2d\u4f7f\u7528<code>if<\/code>\u8bed\u53e5\u6765\u751f\u6210\u6ee1\u8db3\u7279\u5b9a\u6761\u4ef6\u7684\u503c\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def even_numbers(max_num):<\/p>\n<p>    for num in range(max_num):<\/p>\n<p>        if num % 2 == 0:<\/p>\n<p>            yield num<\/p>\n<p>for even in even_numbers(10):<\/p>\n<p>    print(even)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u751f\u6210\u5668\u51fd\u6570<code>even_numbers<\/code>\u751f\u6210\u5c0f\u4e8e<code>max_num<\/code>\u7684\u6240\u6709\u5076\u6570\uff0c\u8f93\u51fa<code>0 2 4 6 8<\/code>\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u751f\u6210\u5668\u8868\u8fbe\u5f0f\u4e0e\u6761\u4ef6<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u5728\u751f\u6210\u5668\u8868\u8fbe\u5f0f\u4e2d\u4f7f\u7528\u6761\u4ef6\u8bed\u53e5\u6765\u751f\u6210\u6ee1\u8db3\u7279\u5b9a\u6761\u4ef6\u7684\u503c\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">max_num = 10<\/p>\n<p>even_numbers = (num for num in range(max_num) if num % 2 == 0)<\/p>\n<p>for even in even_numbers:<\/p>\n<p>    print(even)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u751f\u6210\u5668\u8868\u8fbe\u5f0f\u751f\u6210\u5c0f\u4e8e<code>max_num<\/code>\u7684\u6240\u6709\u5076\u6570\uff0c\u8f93\u51fa<code>0 2 4 6 8<\/code>\u3002<\/p>\n<\/p>\n<p><h3>\u5341\u3001\u4f7f\u7528\u88c5\u9970\u5668\u548c\u6761\u4ef6<\/h3>\n<\/p>\n<p><p>\u88c5\u9970\u5668\u662f\u4e00\u79cd\u7528\u4e8e\u4fee\u6539\u51fd\u6570\u884c\u4e3a\u7684\u9ad8\u7ea7\u6280\u672f\uff0c\u53ef\u4ee5\u5728\u88c5\u9970\u5668\u4e2d\u4f7f\u7528\u6761\u4ef6\u8bed\u53e5\u6765\u63a7\u5236\u51fd\u6570\u7684\u884c\u4e3a\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u57fa\u672c\u88c5\u9970\u5668<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u5728\u88c5\u9970\u5668\u4e2d\u4f7f\u7528<code>if<\/code>\u8bed\u53e5\u6765\u68c0\u67e5\u6761\u4ef6\u5e76\u51b3\u5b9a\u662f\u5426\u8c03\u7528\u88ab\u88c5\u9970\u7684\u51fd\u6570\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def check_positive(func):<\/p>\n<p>    def wrapper(x):<\/p>\n<p>        if x &gt; 0:<\/p>\n<p>            return func(x)<\/p>\n<p>        else:<\/p>\n<p>            return &quot;Input must be positive&quot;<\/p>\n<p>    return wrapper<\/p>\n<p>@check_positive<\/p>\n<p>def square(x):<\/p>\n<p>    return x * x<\/p>\n<p>print(square(4))<\/p>\n<p>print(square(-3))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u88c5\u9970\u5668<code>check_positive<\/code>\u68c0\u67e5\u8f93\u5165\u662f\u5426\u4e3a\u6b63\u6570\uff0c\u5982\u679c\u662f\u6b63\u6570\uff0c\u5219\u8c03\u7528\u88ab\u88c5\u9970\u7684\u51fd\u6570<code>square<\/code>\uff0c\u5426\u5219\u8fd4\u56de\u9519\u8bef\u6d88\u606f\u3002\u8c03\u7528<code>square(4)<\/code>\u65f6\uff0c\u8f93\u51fa<code>16<\/code>\uff0c\u8c03\u7528<code>square(-3)<\/code>\u65f6\uff0c\u8f93\u51fa &quot;Input must be positive&quot;\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u88c5\u9970\u5668\u4e0e\u903b\u8f91\u8fd0\u7b97\u7b26<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u5728\u88c5\u9970\u5668\u4e2d\u4f7f\u7528\u903b\u8f91\u8fd0\u7b97\u7b26\u6765\u7ec4\u5408\u591a\u4e2a\u6761\u4ef6\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def check_range(func):<\/p>\n<p>    def wrapper(x):<\/p>\n<p>        if 0 &lt; x &lt; 100:<\/p>\n<p>            return func(x)<\/p>\n<p>        else:<\/p>\n<p>            return &quot;Input must be between 0 and 100&quot;<\/p>\n<p>    return wrapper<\/p>\n<p>@check_range<\/p>\n<p>def square(x):<\/p>\n<p>    return x * x<\/p>\n<p>print(square(50))<\/p>\n<p>print(square(150))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u88c5\u9970\u5668<code>check_range<\/code>\u68c0\u67e5\u8f93\u5165\u662f\u5426\u57280\u5230100\u4e4b\u95f4\uff0c\u5982\u679c\u662f\uff0c\u5219\u8c03\u7528\u88ab\u88c5\u9970\u7684\u51fd\u6570<code>square<\/code>\uff0c\u5426\u5219\u8fd4\u56de\u9519\u8bef\u6d88\u606f\u3002\u8c03\u7528<code>square(50)<\/code>\u65f6\uff0c\u8f93\u51fa<code>2500<\/code>\uff0c\u8c03\u7528<code>square(150)<\/code>\u65f6\uff0c\u8f93\u51fa &quot;Input must be between 0 and 100&quot;\u3002<\/p>\n<\/p>\n<p><h3>\u5341\u4e00\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u5728Python\u4e2d\uff0c\u901a\u8fc7\u4f7f\u7528\u6761\u4ef6\u8bed\u53e5\uff08\u5982<code>if<\/code>\u3001<code>elif<\/code>\u3001<code>else<\/code>\uff09\u3001\u903b\u8f91\u8fd0\u7b97\u7b26\uff08\u5982<code>and<\/code>\u3001<code>or<\/code>\u3001<code>not<\/code>\uff09\u3001\u5faa\u73af\uff08\u5982<code>for<\/code>\u3001<code>while<\/code>\uff09\u3001\u51fd\u6570\u3001\u5217\u8868\u63a8\u5bfc\u5f0f\u3001\u5b57\u5178\u63a8\u5bfc\u5f0f\u3001\u5f02\u5e38\u5904\u7406\u3001\u7c7b\u4e0e\u5bf9\u8c61\u3001\u751f\u6210\u5668\u548c\u88c5\u9970\u5668\u7b49\u591a\u79cd\u7f16\u7a0b\u7ed3\u6784\uff0c\u53ef\u4ee5\u7075\u6d3b\u5730\u6dfb\u52a0\u8f93\u51fa\u6761\u4ef6\uff0c\u4ece\u800c\u63a7\u5236\u7a0b\u5e8f\u7684\u884c\u4e3a\u548c\u8f93\u51fa\u3002\u8fd9\u4e9b\u6280\u672f\u7684\u7ed3\u5408\u4f7f\u7528\u80fd\u591f\u6709\u6548\u5730\u5904\u7406\u590d\u6742\u7684\u903b\u8f91\u9700\u6c42\uff0c\u63d0\u9ad8\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u548c\u53ef\u7ef4\u62a4\u6027\u3002\u901a\u8fc7\u4e0d\u65ad\u7ec3\u4e60\u548c\u5e94\u7528\u8fd9\u4e9b\u6280\u672f\uff0c\u53ef\u4ee5\u66f4\u597d\u5730\u638c\u63e1\u5728Python\u4e2d\u6dfb\u52a0\u8f93\u51fa\u6761\u4ef6\u7684\u65b9\u6cd5\u548c\u6280\u5de7\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u4f7f\u7528\u6761\u4ef6\u8bed\u53e5\u8fdb\u884c\u8f93\u51fa\u63a7\u5236\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528if\u8bed\u53e5\u6765\u6839\u636e\u7279\u5b9a\u6761\u4ef6\u8f93\u51fa\u4e0d\u540c\u7684\u5185\u5bb9\u3002\u901a\u8fc7\u5b9a\u4e49\u6761\u4ef6\u8868\u8fbe\u5f0f\uff0c\u60a8\u53ef\u4ee5\u63a7\u5236\u7a0b\u5e8f\u7684\u8f93\u51fa\u3002\u4f8b\u5982\uff0c\u60a8\u53ef\u4ee5\u68c0\u67e5\u53d8\u91cf\u7684\u503c\uff0c\u5e76\u6839\u636e\u5b83\u7684\u72b6\u6001\u9009\u62e9\u6027\u5730\u6253\u5370\u4fe1\u606f\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff1a  <\/p>\n<pre><code class=\"language-python\">x = 10\nif x &gt; 5:\n    print(&quot;x\u5927\u4e8e5&quot;)\nelse:\n    print(&quot;x\u5c0f\u4e8e\u6216\u7b49\u4e8e5&quot;)\n<\/code><\/pre>\n<p>\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u53ea\u6709\u5f53x\u5927\u4e8e5\u65f6\uff0c\u624d\u4f1a\u8f93\u51fa&quot;x\u5927\u4e8e5&quot;\u3002<\/p>\n<p><strong>Python\u4e2d\u53ef\u4ee5\u4f7f\u7528\u54ea\u4e9b\u903b\u8f91\u8fd0\u7b97\u7b26\u6765\u5b9e\u73b0\u590d\u6742\u7684\u8f93\u51fa\u6761\u4ef6\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u903b\u8f91\u8fd0\u7b97\u7b26\u5982and\u3001or\u548cnot\u6765\u7ec4\u5408\u591a\u4e2a\u6761\u4ef6\u3002\u8fd9\u4f7f\u5f97\u60a8\u53ef\u4ee5\u521b\u5efa\u66f4\u590d\u6742\u7684\u8f93\u51fa\u6761\u4ef6\u3002\u4f8b\u5982\uff1a  <\/p>\n<pre><code class=\"language-python\">age = 20\nif age &gt;= 18 and age &lt; 65:\n    print(&quot;\u60a8\u662f\u6210\u5e74\u4eba\uff0c\u4f46\u672a\u6ee165\u5c81&quot;)\n<\/code><\/pre>\n<p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u53ea\u6709\u5f53age\u6ee1\u8db3\u4e24\u4e2a\u6761\u4ef6\u65f6\uff0c\u624d\u4f1a\u8f93\u51fa\u76f8\u5e94\u7684\u4fe1\u606f\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728Python\u4e2d\u5904\u7406\u5f02\u5e38\u4ee5\u63a7\u5236\u8f93\u51fa\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u4f7f\u7528try-except\u8bed\u53e5\u53ef\u4ee5\u6709\u6548\u5730\u5904\u7406\u5f02\u5e38\u5e76\u63a7\u5236\u8f93\u51fa\u3002\u5f53\u4ee3\u7801\u5757\u4e2d\u51fa\u73b0\u9519\u8bef\u65f6\uff0c\u60a8\u53ef\u4ee5\u5b9a\u4e49\u76f8\u5e94\u7684\u8f93\u51fa\uff0c\u4ee5\u4fbf\u7528\u6237\u4e86\u89e3\u95ee\u9898\u6240\u5728\u3002\u4f8b\u5982\uff1a  <\/p>\n<pre><code class=\"language-python\">try:\n    result = 10 \/ 0\nexcept ZeroDivisionError:\n    print(&quot;\u53d1\u751f\u4e86\u9664\u4ee5\u96f6\u7684\u9519\u8bef&quot;)\n<\/code><\/pre>\n<p>\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\uff0c\u60a8\u53ef\u4ee5\u786e\u4fdd\u5373\u4f7f\u5728\u53d1\u751f\u9519\u8bef\u65f6\uff0c\u7a0b\u5e8f\u4e5f\u80fd\u7ed9\u51fa\u6e05\u6670\u7684\u53cd\u9988\uff0c\u800c\u4e0d\u4f1a\u76f4\u63a5\u5d29\u6e83\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528\u6761\u4ef6\u8bed\u53e5\uff08\u5982if\u8bed\u53e5\uff09\u3001\u5faa\u73af\u3001\u51fd\u6570\u548c\u5176\u4ed6\u7f16\u7a0b\u7ed3\u6784\u6765\u6dfb\u52a0\u8f93\u51fa\u6761\u4ef6\u3002 \u4f8b\u5982\uff0c\u53ef\u4ee5\u4f7f\u7528 [&hellip;]","protected":false},"author":3,"featured_media":1167761,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1167756"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=1167756"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1167756\/revisions"}],"predecessor-version":[{"id":1167762,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1167756\/revisions\/1167762"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1167761"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1167756"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1167756"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1167756"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}