{"id":1149135,"date":"2025-01-13T16:45:50","date_gmt":"2025-01-13T08:45:50","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1149135.html"},"modified":"2025-01-13T16:45:52","modified_gmt":"2025-01-13T08:45:52","slug":"%e5%a6%82%e4%bd%95python%e6%8a%a5%e8%ad%a6%e5%90%8e%e8%b7%b3%e8%bf%87","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1149135.html","title":{"rendered":"\u5982\u4f55Python\u62a5\u8b66\u540e\u8df3\u8fc7"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25175851\/de99a37c-d30f-44b5-9c31-e61fb4145753.webp\" alt=\"\u5982\u4f55Python\u62a5\u8b66\u540e\u8df3\u8fc7\" \/><\/p>\n<p><p> <strong>Python\u4e2d\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u65b9\u5f0f\u6765\u5904\u7406\u62a5\u8b66\u5e76\u8df3\u8fc7\uff0c\u5982\u4f7f\u7528try-except\u5757\u6765\u6355\u83b7\u5f02\u5e38\u3001\u4f7f\u7528\u8b66\u544a\u6a21\u5757\u4ee5\u53ca\u4f7f\u7528\u6761\u4ef6\u8bed\u53e5\u3002<\/strong> \u672c\u6587\u5c06\u8be6\u7ec6\u8ba8\u8bba\u8fd9\u51e0\u79cd\u65b9\u6cd5\uff0c\u5e76\u63d0\u4f9b\u76f8\u5173\u4ee3\u7801\u793a\u4f8b\u3002<\/p>\n<\/p>\n<p><p>\u5176\u4e2d\uff0c<strong>try-except\u5757<\/strong>\u662f\u4e00\u79cd\u5e38\u89c1\u4e14\u6709\u6548\u7684\u65b9\u6cd5\uff0c\u7528\u6765\u6355\u83b7\u5f02\u5e38\u5e76\u5141\u8bb8\u7a0b\u5e8f\u7ee7\u7eed\u8fd0\u884c\u3002\u901a\u8fc7\u8fd9\u79cd\u65b9\u6cd5\uff0c\u53ef\u4ee5\u5728\u53d1\u751f\u5f02\u5e38\u65f6\u6267\u884c\u7279\u5b9a\u7684\u4ee3\u7801\uff0c\u4ece\u800c\u907f\u514d\u7a0b\u5e8f\u4e2d\u65ad\u3002\u4ee5\u4e0b\u662f\u8be6\u7ec6\u4ecb\u7ecd\uff1a<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u4f7f\u7528 try-except \u5757<\/h3>\n<\/p>\n<p><p>\u5728Python\u4e2d\uff0ctry-except\u5757\u662f\u5904\u7406\u5f02\u5e38\u7684\u4e3b\u8981\u65b9\u6cd5\u3002try\u5757\u4e2d\u7684\u4ee3\u7801\u4f1a\u88ab\u6267\u884c\uff0c\u5982\u679c\u53d1\u751f\u5f02\u5e38\uff0c\u63a7\u5236\u6d41\u4f1a\u7acb\u5373\u8df3\u5230except\u5757\u3002\u8fd9\u6837\u53ef\u4ee5\u786e\u4fdd\u7a0b\u5e8f\u5728\u53d1\u751f\u5f02\u5e38\u65f6\u4e0d\u4f1a\u5d29\u6e83\uff0c\u800c\u662f\u6267\u884c\u6211\u4eec\u5b9a\u4e49\u7684\u5904\u7406\u903b\u8f91\uff0c\u7136\u540e\u7ee7\u7eed\u8fd0\u884c\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u57fa\u672c\u8bed\u6cd5<\/h4>\n<\/p>\n<p><p>try-except\u5757\u7684\u57fa\u672c\u8bed\u6cd5\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">try:<\/p>\n<p>    # \u53ef\u80fd\u4f1a\u5f15\u53d1\u5f02\u5e38\u7684\u4ee3\u7801<\/p>\n<p>except \u5f02\u5e38\u7c7b\u578b as e:<\/p>\n<p>    # \u5904\u7406\u5f02\u5e38\u7684\u4ee3\u7801<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2\u3001\u793a\u4f8b\u4ee3\u7801<\/h4>\n<\/p>\n<p><p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\uff0c\u5c55\u793a\u4e86\u5982\u4f55\u4f7f\u7528try-except\u5757\u6355\u83b7\u5f02\u5e38\u5e76\u8df3\u8fc7\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">try:<\/p>\n<p>    result = 10 \/ 0<\/p>\n<p>except ZeroDivisionError as e:<\/p>\n<p>    print(f&quot;\u8b66\u544a: \u53d1\u751f\u5f02\u5e38 - {e}&quot;)<\/p>\n<h2><strong>\u7ee7\u7eed\u6267\u884c<\/strong><\/h2>\n<p>print(&quot;\u7a0b\u5e8f\u7ee7\u7eed\u8fd0\u884c&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>10 \/ 0<\/code>\u4f1a\u5f15\u53d1<code>ZeroDivisionError<\/code>\u5f02\u5e38\uff0c\u4f46\u7531\u4e8e\u6211\u4eec\u5728except\u5757\u4e2d\u6355\u83b7\u4e86\u8fd9\u4e2a\u5f02\u5e38\uff0c\u7a0b\u5e8f\u4e0d\u4f1a\u5d29\u6e83\uff0c\u800c\u662f\u8f93\u51fa\u8b66\u544a\u6d88\u606f\u5e76\u7ee7\u7eed\u8fd0\u884c\u3002<\/p>\n<\/p>\n<p><h4>3\u3001\u6355\u83b7\u591a\u79cd\u5f02\u5e38<\/h4>\n<\/p>\n<p><p>\u6709\u65f6\uff0c\u6211\u4eec\u53ef\u80fd\u9700\u8981\u6355\u83b7\u591a\u79cd\u7c7b\u578b\u7684\u5f02\u5e38\u3002\u53ef\u4ee5\u901a\u8fc7\u5728except\u5757\u4e2d\u5217\u51fa\u591a\u4e2a\u5f02\u5e38\u7c7b\u578b\u6765\u5b9e\u73b0\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">try:<\/p>\n<p>    # \u53ef\u80fd\u4f1a\u5f15\u53d1\u591a\u79cd\u5f02\u5e38\u7684\u4ee3\u7801<\/p>\n<p>except (TypeError, ValueError) as e:<\/p>\n<p>    print(f&quot;\u8b66\u544a: \u53d1\u751f\u5f02\u5e38 - {e}&quot;)<\/p>\n<h2><strong>\u7ee7\u7eed\u6267\u884c<\/strong><\/h2>\n<p>print(&quot;\u7a0b\u5e8f\u7ee7\u7eed\u8fd0\u884c&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e8c\u3001\u4f7f\u7528\u8b66\u544a\u6a21\u5757<\/h3>\n<\/p>\n<p><p>Python\u63d0\u4f9b\u4e86<code>warnings<\/code>\u6a21\u5757\uff0c\u53ef\u4ee5\u7528\u6765\u53d1\u51fa\u8b66\u544a\u800c\u4e0d\u662f\u5f15\u53d1\u5f02\u5e38\u3002\u4f7f\u7528<code>warnings<\/code>\u6a21\u5757\u53ef\u4ee5\u5728\u4e0d\u6253\u65ad\u7a0b\u5e8f\u6267\u884c\u7684\u60c5\u51b5\u4e0b\u53d1\u51fa\u8b66\u544a\u6d88\u606f\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u57fa\u672c\u4f7f\u7528<\/h4>\n<\/p>\n<p><p><code>warnings<\/code>\u6a21\u5757\u7684\u57fa\u672c\u4f7f\u7528\u65b9\u6cd5\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import warnings<\/p>\n<p>warnings.warn(&quot;\u8fd9\u662f\u4e00\u4e2a\u8b66\u544a\u6d88\u606f&quot;)<\/p>\n<h2><strong>\u7ee7\u7eed\u6267\u884c<\/strong><\/h2>\n<p>print(&quot;\u7a0b\u5e8f\u7ee7\u7eed\u8fd0\u884c&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2\u3001\u5ffd\u7565\u8b66\u544a<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e\u8fc7\u6ee4\u5668\u6765\u5ffd\u7565\u8b66\u544a\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import warnings<\/p>\n<p>warnings.filterwarnings(&quot;ignore&quot;)<\/p>\n<p>warnings.warn(&quot;\u8fd9\u662f\u4e00\u4e2a\u8b66\u544a\u6d88\u606f&quot;)<\/p>\n<h2><strong>\u7ee7\u7eed\u6267\u884c<\/strong><\/h2>\n<p>print(&quot;\u7a0b\u5e8f\u7ee7\u7eed\u8fd0\u884c&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u8b66\u544a\u6d88\u606f\u4f1a\u88ab\u5ffd\u7565\uff0c\u7a0b\u5e8f\u7ee7\u7eed\u8fd0\u884c\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u4f7f\u7528\u6761\u4ef6\u8bed\u53e5<\/h3>\n<\/p>\n<p><p>\u901a\u8fc7\u6761\u4ef6\u8bed\u53e5\uff0c\u53ef\u4ee5\u5728\u7279\u5b9a\u60c5\u51b5\u4e0b\u8df3\u8fc7\u67d0\u4e9b\u4ee3\u7801\u6bb5\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u4f7f\u7528if\u8bed\u53e5\u68c0\u67e5\u67d0\u4e2a\u6761\u4ef6\u662f\u5426\u4e3a\u771f\uff0c\u5982\u679c\u4e3a\u771f\u5219\u8df3\u8fc7\u67d0\u4e9b\u4ee3\u7801\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u57fa\u672c\u4f7f\u7528<\/h4>\n<\/p>\n<p><p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\uff0c\u5c55\u793a\u4e86\u5982\u4f55\u4f7f\u7528\u6761\u4ef6\u8bed\u53e5\u8df3\u8fc7\u67d0\u4e9b\u4ee3\u7801\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">condition = True<\/p>\n<p>if not condition:<\/p>\n<p>    # \u4e0d\u6267\u884c\u8fd9\u6bb5\u4ee3\u7801<\/p>\n<p>    print(&quot;\u8fd9\u6bb5\u4ee3\u7801\u4f1a\u88ab\u8df3\u8fc7&quot;)<\/p>\n<h2><strong>\u7ee7\u7eed\u6267\u884c<\/strong><\/h2>\n<p>print(&quot;\u7a0b\u5e8f\u7ee7\u7eed\u8fd0\u884c&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2\u3001\u793a\u4f8b\u4ee3\u7801<\/h4>\n<\/p>\n<p><p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u66f4\u590d\u6742\u7684\u4f8b\u5b50\uff0c\u5c55\u793a\u4e86\u5982\u4f55\u4f7f\u7528\u6761\u4ef6\u8bed\u53e5\u5904\u7406\u7279\u5b9a\u60c5\u51b5\u5e76\u8df3\u8fc7\u67d0\u4e9b\u4ee3\u7801\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">data = [1, 2, 3, None, 5]<\/p>\n<p>for item in data:<\/p>\n<p>    if item is None:<\/p>\n<p>        print(&quot;\u8b66\u544a: \u9047\u5230None\u503c\uff0c\u8df3\u8fc7&quot;)<\/p>\n<p>        continue<\/p>\n<p>    # \u5904\u7406\u6570\u636e<\/p>\n<p>    print(f&quot;\u5904\u7406\u6570\u636e: {item}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u5f53\u9047\u5230<code>None<\/code>\u503c\u65f6\uff0c\u4f1a\u8f93\u51fa\u8b66\u544a\u6d88\u606f\u5e76\u8df3\u8fc7\u5bf9\u8be5\u503c\u7684\u5904\u7406\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u7efc\u5408\u793a\u4f8b<\/h3>\n<\/p>\n<p><p>\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u7efc\u5408\u4f7f\u7528try-except\u5757\u3001\u8b66\u544a\u6a21\u5757\u548c\u6761\u4ef6\u8bed\u53e5\u6765\u5904\u7406\u5f02\u5e38\u60c5\u51b5\u5e76\u8df3\u8fc7\u7279\u5b9a\u4ee3\u7801\u6bb5\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7efc\u5408\u793a\u4f8b\uff0c\u5c55\u793a\u4e86\u5982\u4f55\u5728\u4e00\u4e2a\u5b9e\u9645\u5e94\u7528\u4e2d\u4f7f\u7528\u8fd9\u4e9b\u6280\u672f\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import warnings<\/p>\n<p>def process_data(data):<\/p>\n<p>    for item in data:<\/p>\n<p>        try:<\/p>\n<p>            if item is None:<\/p>\n<p>                warnings.warn(&quot;\u8b66\u544a: \u9047\u5230None\u503c\uff0c\u8df3\u8fc7&quot;)<\/p>\n<p>                continue<\/p>\n<p>            result = 10 \/ item<\/p>\n<p>        except ZeroDivisionError as e:<\/p>\n<p>            print(f&quot;\u8b66\u544a: \u53d1\u751f\u5f02\u5e38 - {e}&quot;)<\/p>\n<p>            continue<\/p>\n<p>        except TypeError as e:<\/p>\n<p>            print(f&quot;\u8b66\u544a: \u53d1\u751f\u5f02\u5e38 - {e}&quot;)<\/p>\n<p>            continue<\/p>\n<p>        # \u5904\u7406\u6570\u636e<\/p>\n<p>        print(f&quot;\u5904\u7406\u6570\u636e: {result}&quot;)<\/p>\n<p>data = [10, 5, 0, None, &quot;a&quot;, 2]<\/p>\n<p>process_data(data)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u7efc\u5408\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u5b9a\u4e49\u4e86\u4e00\u4e2a<code>process_data<\/code>\u51fd\u6570\uff0c\u63a5\u6536\u4e00\u4e2a\u6570\u636e\u5217\u8868\u4f5c\u4e3a\u53c2\u6570\u3002\u901a\u8fc7try-except\u5757\u3001\u8b66\u544a\u6a21\u5757\u548c\u6761\u4ef6\u8bed\u53e5\uff0c\u6211\u4eec\u80fd\u591f\u5904\u7406\u4e0d\u540c\u7c7b\u578b\u7684\u5f02\u5e38\u60c5\u51b5\u5e76\u8df3\u8fc7\u7279\u5b9a\u4ee3\u7801\u6bb5\uff0c\u4ece\u800c\u786e\u4fdd\u7a0b\u5e8f\u80fd\u591f\u7ee7\u7eed\u8fd0\u884c\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u65b9\u5f0f\u5904\u7406\u62a5\u8b66\u5e76\u8df3\u8fc7\uff0c\u5305\u62ec\u4f7f\u7528try-except\u5757\u3001\u8b66\u544a\u6a21\u5757\u548c\u6761\u4ef6\u8bed\u53e5\u3002<strong>try-except\u5757\u662f\u6355\u83b7\u5f02\u5e38\u7684\u4e3b\u8981\u65b9\u6cd5<\/strong>\uff0c\u53ef\u4ee5\u786e\u4fdd\u7a0b\u5e8f\u5728\u53d1\u751f\u5f02\u5e38\u65f6\u4e0d\u4f1a\u5d29\u6e83\uff0c\u800c\u662f\u6267\u884c\u6211\u4eec\u5b9a\u4e49\u7684\u5904\u7406\u903b\u8f91\u5e76\u7ee7\u7eed\u8fd0\u884c\u3002<strong>\u8b66\u544a\u6a21\u5757\u53ef\u4ee5\u53d1\u51fa\u8b66\u544a\u800c\u4e0d\u6253\u65ad\u7a0b\u5e8f\u6267\u884c<\/strong>\uff0c\u5e76\u4e14\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e\u8fc7\u6ee4\u5668\u6765\u5ffd\u7565\u8b66\u544a\u3002<strong>\u6761\u4ef6\u8bed\u53e5\u53ef\u4ee5\u5728\u7279\u5b9a\u60c5\u51b5\u4e0b\u8df3\u8fc7\u67d0\u4e9b\u4ee3\u7801\u6bb5<\/strong>\u3002\u901a\u8fc7\u7efc\u5408\u4f7f\u7528\u8fd9\u4e9b\u6280\u672f\uff0c\u53ef\u4ee5\u7f16\u5199\u5065\u58ee\u7684\u4ee3\u7801\u6765\u5904\u7406\u5404\u79cd\u5f02\u5e38\u60c5\u51b5\u5e76\u786e\u4fdd\u7a0b\u5e8f\u80fd\u591f\u7ee7\u7eed\u8fd0\u884c\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u4f7f\u7528Python\u8bbe\u7f6e\u62a5\u8b66\u7cfb\u7edf\u5e76\u4f7f\u5176\u5728\u62a5\u8b66\u540e\u81ea\u52a8\u8df3\u8fc7\u7279\u5b9a\u64cd\u4f5c\uff1f<\/strong><\/p>\n<p>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u5f02\u5e38\u5904\u7406\u673a\u5236\u6765\u8bbe\u7f6e\u62a5\u8b66\u7cfb\u7edf\u3002\u901a\u8fc7try-except\u8bed\u53e5\uff0c\u53ef\u4ee5\u6355\u83b7\u7279\u5b9a\u7684\u9519\u8bef\u5e76\u5728\u62a5\u8b66\u540e\u6267\u884c\u8df3\u8fc7\u64cd\u4f5c\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff1a<\/p>\n<pre><code class=\"language-python\">try:\n    # \u53ef\u80fd\u5f15\u53d1\u5f02\u5e38\u7684\u4ee3\u7801\n    risky_operation()\nexcept SomeSpecificException as e:\n    print(f&quot;\u62a5\u8b66: {e}&quot;)\n    # \u8df3\u8fc7\u7279\u5b9a\u64cd\u4f5c\n<\/code><\/pre>\n<p><strong>\u5982\u4f55\u5728Python\u4e2d\u5b9e\u73b0\u62a5\u8b66\u5e76\u8bb0\u5f55\u9519\u8bef\u4fe1\u606f\uff1f<\/strong><\/p>\n<p>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u65e5\u5fd7\u6a21\u5757\uff08logging\uff09\u6765\u8bb0\u5f55\u62a5\u8b66\u4fe1\u606f\u3002\u901a\u8fc7\u8bbe\u7f6e\u65e5\u5fd7\u7ea7\u522b\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u6355\u83b7\u548c\u5b58\u50a8\u9519\u8bef\u4fe1\u606f\u3002\u793a\u4f8b\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"language-python\">import logging\n\nlogging.basicConfig(level=logging.ERROR)\n\ntry:\n    risky_operation()\nexcept SomeSpecificException as e:\n    logging.error(f&quot;\u62a5\u8b66: {e}&quot;)\n<\/code><\/pre>\n<p><strong>\u5982\u4f55\u5728Python\u4e2d\u4f7f\u7528\u6761\u4ef6\u5224\u65ad\u6765\u51b3\u5b9a\u662f\u5426\u62a5\u8b66\u5e76\u8df3\u8fc7\u67d0\u4e9b\u64cd\u4f5c\uff1f<\/strong><\/p>\n<p>\u53ef\u4ee5\u901a\u8fc7\u6761\u4ef6\u5224\u65ad\u6765\u7075\u6d3b\u63a7\u5236\u62a5\u8b66\u673a\u5236\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u5728\u7279\u5b9a\u6761\u4ef6\u4e0b\u51b3\u5b9a\u662f\u5426\u9700\u8981\u6267\u884c\u62a5\u8b66\u64cd\u4f5c\u3002\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"language-python\">if some_condition:\n    try:\n        risky_operation()\n    except SomeSpecificException as e:\n        print(f&quot;\u62a5\u8b66: {e}&quot;)\nelse:\n    print(&quot;\u6761\u4ef6\u4e0d\u6ee1\u8db3\uff0c\u8df3\u8fc7\u62a5\u8b66&quot;)\n<\/code><\/pre>\n<p>\u8fd9\u4e9b\u65b9\u6cd5\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u8005\u5728Python\u4e2d\u8bbe\u7f6e\u62a5\u8b66\u7cfb\u7edf\uff0c\u5e76\u5728\u53d1\u751f\u8b66\u62a5\u65f6\u7075\u6d3b\u5730\u8df3\u8fc7\u7279\u5b9a\u64cd\u4f5c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Python\u4e2d\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u65b9\u5f0f\u6765\u5904\u7406\u62a5\u8b66\u5e76\u8df3\u8fc7\uff0c\u5982\u4f7f\u7528try-except\u5757\u6765\u6355\u83b7\u5f02\u5e38\u3001\u4f7f\u7528\u8b66\u544a\u6a21\u5757\u4ee5\u53ca\u4f7f\u7528\u6761 [&hellip;]","protected":false},"author":3,"featured_media":1149138,"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\/1149135"}],"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=1149135"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1149135\/revisions"}],"predecessor-version":[{"id":1149140,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1149135\/revisions\/1149140"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1149138"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1149135"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1149135"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1149135"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}