{"id":935609,"date":"2024-12-26T18:56:38","date_gmt":"2024-12-26T10:56:38","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/935609.html"},"modified":"2024-12-26T18:56:41","modified_gmt":"2024-12-26T10:56:41","slug":"python%e5%a6%82%e4%bd%95debug%e6%94%bb%e7%95%a5","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/935609.html","title":{"rendered":"python\u5982\u4f55debug\u653b\u7565"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25072147\/38442eb8-c2e6-4d93-810c-016df3cbcf85.webp\" alt=\"python\u5982\u4f55debug\u653b\u7565\" \/><\/p>\n<p><p> \u5f00\u5934\u6bb5\u843d\uff1a<br \/><strong>Python\u8c03\u8bd5\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528\u5185\u7f6e\u7684\u8c03\u8bd5\u5de5\u5177\u3001\u65e5\u5fd7\u8bb0\u5f55\u3001\u65ad\u70b9\u548c\u5355\u6b65\u6267\u884c\u3001\u5f02\u5e38\u5904\u7406\u7b49\u65b9\u6cd5\u6765\u8fdb\u884c\u3002<\/strong>\u5176\u4e2d\uff0c\u4f7f\u7528Python\u7684\u5185\u7f6e\u8c03\u8bd5\u5de5\u5177\uff08\u5982pdb\u6a21\u5757\uff09\u662f\u6700\u4e3a\u76f4\u63a5\u548c\u6709\u6548\u7684\u65b9\u5f0f\u3002pdb\u6a21\u5757\u63d0\u4f9b\u4e86\u4e00\u4e2a\u5f3a\u5927\u7684\u4ea4\u4e92\u5f0f\u8c03\u8bd5\u73af\u5883\uff0c\u5141\u8bb8\u5f00\u53d1\u8005\u9010\u6b65\u6267\u884c\u4ee3\u7801\u3001\u68c0\u67e5\u53d8\u91cf\u503c\u3001\u8bbe\u7f6e\u65ad\u70b9\u7b49\u3002\u4f7f\u7528pdb\u8fdb\u884c\u8c03\u8bd5\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7\u5728\u4ee3\u7801\u4e2d\u63d2\u5165 <code>import pdb; pdb.set_trace()<\/code> \u6765\u542f\u52a8\u8c03\u8bd5\u4f1a\u8bdd\uff0c\u8fd9\u6837\u53ef\u4ee5\u5728\u7a0b\u5e8f\u7684\u7279\u5b9a\u4f4d\u7f6e\u6682\u505c\u6267\u884c\uff0c\u5e76\u8fdb\u5165\u8c03\u8bd5\u6a21\u5f0f\u3002\u5728\u8fd9\u79cd\u6a21\u5f0f\u4e0b\uff0c\u4f60\u53ef\u4ee5\u9010\u884c\u6267\u884c\u4ee3\u7801\u3001\u67e5\u770b\u548c\u4fee\u6539\u53d8\u91cf\u3001\u8c03\u7528\u51fd\u6570\u7b49\uff0c\u4ece\u800c\u66f4\u6df1\u5165\u5730\u4e86\u89e3\u7a0b\u5e8f\u7684\u8fd0\u884c\u60c5\u51b5\u5e76\u627e\u51fa\u95ee\u9898\u6240\u5728\u3002<\/p>\n<\/p>\n<p><h2>\u4e00\u3001\u4f7f\u7528PDB\u8fdb\u884c\u8c03\u8bd5<\/h2>\n<\/p>\n<p><p>Python\u7684pdb\u6a21\u5757\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u5185\u7f6e\u8c03\u8bd5\u5de5\u5177\uff0c\u9002\u5408\u7528\u4e8e\u8c03\u8bd5Python\u4ee3\u7801\u3002<\/p>\n<\/p>\n<p><h3>1.1 PDB\u57fa\u672c\u7528\u6cd5<\/h3>\n<\/p>\n<p><p>\u8981\u4f7f\u7528pdb\u8fdb\u884c\u8c03\u8bd5\uff0c\u53ea\u9700\u5728\u4ee3\u7801\u4e2d\u63d2\u5165 <code>import pdb; pdb.set_trace()<\/code>\uff0c\u8fd9\u6837\u7a0b\u5e8f\u5728\u8fd0\u884c\u5230\u8be5\u884c\u65f6\u4f1a\u6682\u505c\uff0c\u5e76\u8fdb\u5165pdb\u4ea4\u4e92\u6a21\u5f0f\u3002\u5728\u8fd9\u4e2a\u6a21\u5f0f\u4e0b\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u5404\u79cd\u547d\u4ee4\u6765\u63a7\u5236\u7a0b\u5e8f\u7684\u6267\u884c\u3002<\/p>\n<\/p>\n<ul>\n<li><strong>n\uff08next\uff09<\/strong>\uff1a\u6267\u884c\u4e0b\u4e00\u884c\u4ee3\u7801\uff0c\u4e0d\u8fdb\u5165\u51fd\u6570\u5185\u90e8\u3002<\/li>\n<li><strong>s\uff08step\uff09<\/strong>\uff1a\u6267\u884c\u4e0b\u4e00\u884c\u4ee3\u7801\uff0c\u5982\u679c\u662f\u51fd\u6570\u8c03\u7528\uff0c\u5219\u8fdb\u5165\u51fd\u6570\u5185\u90e8\u3002<\/li>\n<li><strong>c\uff08continue\uff09<\/strong>\uff1a\u7ee7\u7eed\u6267\u884c\u4ee3\u7801\uff0c\u76f4\u5230\u9047\u5230\u4e0b\u4e00\u4e2a\u65ad\u70b9\u3002<\/li>\n<li><strong>l\uff08list\uff09<\/strong>\uff1a\u67e5\u770b\u5f53\u524d\u4ee3\u7801\u7247\u6bb5\u3002<\/li>\n<li><strong>p\uff08print\uff09<\/strong>\uff1a\u6253\u5370\u53d8\u91cf\u7684\u503c\u3002<\/li>\n<\/ul>\n<p><h3>1.2 \u8bbe\u7f6e\u65ad\u70b9<\/h3>\n<\/p>\n<p><p>\u9664\u4e86\u76f4\u63a5\u4f7f\u7528 <code>set_trace()<\/code> \u8fdb\u884c\u8c03\u8bd5\u5916\uff0c\u4f60\u8fd8\u53ef\u4ee5\u5728pdb\u4e2d\u52a8\u6001\u8bbe\u7f6e\u65ad\u70b9\u3002\u4f7f\u7528 <code>break<\/code> \u547d\u4ee4\u53ef\u4ee5\u8bbe\u7f6e\u65ad\u70b9\uff0c\u6bd4\u5982 <code>break filename:line_number<\/code>\u3002\u5728\u7a0b\u5e8f\u8fd0\u884c\u4e2d\uff0c\u8fd9\u4e9b\u65ad\u70b9\u53ef\u4ee5\u5e2e\u52a9\u4f60\u6682\u505c\u7a0b\u5e8f\u5e76\u68c0\u67e5\u5f53\u524d\u7684\u6267\u884c\u72b6\u6001\u3002<\/p>\n<\/p>\n<p><h2>\u4e8c\u3001\u5229\u7528\u65e5\u5fd7\u8bb0\u5f55<\/h2>\n<\/p>\n<p><p>\u65e5\u5fd7\u8bb0\u5f55\u662f\u8c03\u8bd5\u7684\u4e00\u79cd\u91cd\u8981\u65b9\u5f0f\uff0c\u5c24\u5176\u662f\u5728\u9700\u8981\u957f\u65f6\u95f4\u8fd0\u884c\u7684\u7a0b\u5e8f\u4e2d\u6216\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u3002<\/p>\n<\/p>\n<p><h3>2.1 Python\u7684Logging\u6a21\u5757<\/h3>\n<\/p>\n<p><p>Python\u63d0\u4f9b\u4e86logging\u6a21\u5757\uff0c\u53ef\u4ee5\u8f7b\u677e\u5730\u5c06\u65e5\u5fd7\u4fe1\u606f\u8f93\u51fa\u5230\u63a7\u5236\u53f0\u6216\u6587\u4ef6\u4e2d\u3002\u901a\u8fc7\u8bbe\u7f6e\u4e0d\u540c\u7684\u65e5\u5fd7\u7ea7\u522b\uff08DEBUG\u3001INFO\u3001WARNING\u3001ERROR\u3001CRITICAL\uff09\uff0c\u4f60\u53ef\u4ee5\u63a7\u5236\u54ea\u4e9b\u4fe1\u606f\u88ab\u8bb0\u5f55\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import logging<\/p>\n<p>logging.basicConfig(level=logging.DEBUG)<\/p>\n<p>logging.debug(&#39;This is a debug message&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2.2 \u65e5\u5fd7\u7684\u597d\u5904<\/h3>\n<\/p>\n<p><p>\u65e5\u5fd7\u4e0d\u4ec5\u80fd\u5e2e\u52a9\u4f60\u8ddf\u8e2a\u7a0b\u5e8f\u7684\u6267\u884c\u8fc7\u7a0b\uff0c\u8fd8\u80fd\u5728\u7a0b\u5e8f\u51fa\u9519\u65f6\u63d0\u4f9b\u6709\u7528\u7684\u4e0a\u4e0b\u6587\u4fe1\u606f\u3002\u901a\u8fc7\u5206\u6790\u65e5\u5fd7\uff0c\u4f60\u53ef\u4ee5\u66f4\u5feb\u5730\u5b9a\u4f4d\u95ee\u9898\u6240\u5728\uff0c\u5c24\u5176\u662f\u5728\u590d\u6742\u7684\u7cfb\u7edf\u4e2d\u3002<\/p>\n<\/p>\n<p><h2>\u4e09\u3001\u4f7f\u7528\u5f02\u5e38\u5904\u7406<\/h2>\n<\/p>\n<p><p>\u5728Python\u4e2d\uff0c\u5f02\u5e38\u5904\u7406\u662f\u4fdd\u8bc1\u7a0b\u5e8f\u5065\u58ee\u6027\u7684\u91cd\u8981\u624b\u6bb5\u3002\u901a\u8fc7\u5408\u7406\u7684\u5f02\u5e38\u6355\u83b7\u548c\u5904\u7406\uff0c\u53ef\u4ee5\u907f\u514d\u7a0b\u5e8f\u5d29\u6e83\uff0c\u5e76\u63d0\u4f9b\u6709\u7528\u7684\u9519\u8bef\u4fe1\u606f\u3002<\/p>\n<\/p>\n<p><h3>3.1 try-except\u8bed\u53e5<\/h3>\n<\/p>\n<p><p>\u4f7f\u7528try-except\u8bed\u53e5\u53ef\u4ee5\u6355\u83b7\u7a0b\u5e8f\u8fd0\u884c\u65f6\u7684\u5f02\u5e38\uff0c\u5e76\u5bf9\u5176\u8fdb\u884c\u5904\u7406\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">try:<\/p>\n<p>    # \u53ef\u80fd\u53d1\u751f\u5f02\u5e38\u7684\u4ee3\u7801<\/p>\n<p>    result = 10 \/ 0<\/p>\n<p>except ZeroDivisionError as e:<\/p>\n<p>    print(f&quot;Caught an exception: {e}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>3.2 \u81ea\u5b9a\u4e49\u5f02\u5e38<\/h3>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u4f60\u53ef\u80fd\u9700\u8981\u5b9a\u4e49\u81ea\u5df1\u7684\u5f02\u5e38\u7c7b\u578b\uff0c\u4ee5\u4fbf\u66f4\u7cbe\u786e\u5730\u5904\u7406\u7279\u5b9a\u7684\u9519\u8bef\u60c5\u5f62\u3002\u81ea\u5b9a\u4e49\u5f02\u5e38\u53ef\u4ee5\u7ee7\u627f\u81eaPython\u7684Exception\u7c7b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">class MyCustomError(Exception):<\/p>\n<p>    pass<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>\u56db\u3001\u4f7f\u7528\u5355\u5143\u6d4b\u8bd5<\/h2>\n<\/p>\n<p><p>\u5355\u5143\u6d4b\u8bd5\u662f\u4e00\u79cd\u6709\u6548\u7684\u8c03\u8bd5\u548c\u9a8c\u8bc1\u5de5\u5177\uff0c\u80fd\u591f\u786e\u4fdd\u4ee3\u7801\u5728\u4fee\u6539\u65f6\u4ecd\u7136\u4fdd\u6301\u6b63\u786e\u6027\u3002<\/p>\n<\/p>\n<p><h3>4.1 \u7f16\u5199\u5355\u5143\u6d4b\u8bd5<\/h3>\n<\/p>\n<p><p>Python\u7684unittest\u6a21\u5757\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u5355\u5143\u6d4b\u8bd5\u529f\u80fd\uff0c\u53ef\u4ee5\u5e2e\u52a9\u4f60\u9a8c\u8bc1\u4ee3\u7801\u7684\u6b63\u786e\u6027\u548c\u9c81\u68d2\u6027\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import unittest<\/p>\n<p>def add(a, b):<\/p>\n<p>    return a + b<\/p>\n<p>class TestMathFunctions(unittest.TestCase):<\/p>\n<p>    def test_add(self):<\/p>\n<p>        self.assertEqual(add(1, 2), 3)<\/p>\n<p>if __name__ == &#39;__m<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>n__&#39;:<\/p>\n<p>    unittest.main()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>4.2 \u5229\u7528\u6d4b\u8bd5\u8fdb\u884c\u8c03\u8bd5<\/h3>\n<\/p>\n<p><p>\u5728\u7f16\u5199\u5355\u5143\u6d4b\u8bd5\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7\u6d4b\u8bd5\u7528\u4f8b\u66b4\u9732\u4ee3\u7801\u4e2d\u7684\u9519\u8bef\uff0c\u5e76\u5229\u7528\u8c03\u8bd5\u5de5\u5177\u6216\u65e5\u5fd7\u5206\u6790\u6765\u67e5\u627e\u95ee\u9898\u6839\u6e90\u3002<\/p>\n<\/p>\n<p><h2>\u4e94\u3001\u4f7f\u7528\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09<\/h2>\n<\/p>\n<p><p>\u73b0\u4ee3\u7684\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08\u5982PyCharm\u3001Visual Studio Code\u7b49\uff09\u90fd\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u8c03\u8bd5\u529f\u80fd\uff0c\u80fd\u591f\u5927\u5927\u63d0\u9ad8\u8c03\u8bd5\u7684\u6548\u7387\u3002<\/p>\n<\/p>\n<p><h3>5.1 \u8bbe\u7f6e\u65ad\u70b9<\/h3>\n<\/p>\n<p><p>\u5728IDE\u4e2d\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u70b9\u51fb\u884c\u53f7\u65c1\u8fb9\u7684\u7a7a\u767d\u5904\u8f7b\u677e\u8bbe\u7f6e\u65ad\u70b9\u3002\u5728\u7a0b\u5e8f\u8fd0\u884c\u65f6\uff0c\u7a0b\u5e8f\u4f1a\u5728\u65ad\u70b9\u5904\u6682\u505c\uff0c\u4f60\u53ef\u4ee5\u68c0\u67e5\u53d8\u91cf\u503c\u3001\u6267\u884c\u5355\u6b65\u64cd\u4f5c\u7b49\u3002<\/p>\n<\/p>\n<p><h3>5.2 \u8c03\u8bd5\u5de5\u5177<\/h3>\n<\/p>\n<p><p>IDE\u901a\u5e38\u63d0\u4f9b\u56fe\u5f62\u5316\u7684\u8c03\u8bd5\u5de5\u5177\uff0c\u4f7f\u5f97\u8c03\u8bd5\u8fc7\u7a0b\u66f4\u52a0\u76f4\u89c2\u548c\u4fbf\u6377\u3002\u901a\u8fc7\u8fd9\u4e9b\u5de5\u5177\uff0c\u4f60\u53ef\u4ee5\u5728\u8c03\u8bd5\u8fc7\u7a0b\u4e2d\u52a8\u6001\u4fee\u6539\u53d8\u91cf\u3001\u8bc4\u4f30\u8868\u8fbe\u5f0f\u7b49\u3002<\/p>\n<\/p>\n<p><h2>\u516d\u3001\u4f7f\u7528\u5728\u7ebf\u8c03\u8bd5\u5de5\u5177<\/h2>\n<\/p>\n<p><p>\u9664\u4e86\u672c\u5730\u7684\u8c03\u8bd5\u5de5\u5177\uff0c\u5728\u7ebf\u8c03\u8bd5\u5de5\u5177\u4e5f\u662f\u4e00\u79cd\u65b9\u4fbf\u7684\u9009\u62e9\uff0c\u7279\u522b\u662f\u5728\u9700\u8981\u534f\u4f5c\u6216\u5206\u4eab\u4ee3\u7801\u65f6\u3002<\/p>\n<\/p>\n<p><h3>6.1 Python Tutor<\/h3>\n<\/p>\n<p><p>Python Tutor\u662f\u4e00\u4e2a\u5728\u7ebf\u5de5\u5177\uff0c\u53ef\u4ee5\u53ef\u89c6\u5316Python\u4ee3\u7801\u7684\u6267\u884c\u8fc7\u7a0b\u3002\u901a\u8fc7\u8fd9\u4e2a\u5de5\u5177\uff0c\u4f60\u53ef\u4ee5\u76f4\u89c2\u5730\u4e86\u89e3\u4ee3\u7801\u7684\u6267\u884c\u6d41\u7a0b\u548c\u6570\u636e\u53d8\u5316\u3002<\/p>\n<\/p>\n<p><h3>6.2 Repl.it<\/h3>\n<\/p>\n<p><p>Repl.it\u662f\u4e00\u4e2a\u5728\u7ebf\u7f16\u7a0b\u5e73\u53f0\uff0c\u652f\u6301\u591a\u79cd\u7f16\u7a0b\u8bed\u8a00\uff0c\u5305\u62ecPython\u3002\u5b83\u63d0\u4f9b\u4e86\u5728\u7ebf\u7f16\u8f91\u3001\u8fd0\u884c\u548c\u8c03\u8bd5\u4ee3\u7801\u7684\u529f\u80fd\uff0c\u975e\u5e38\u9002\u5408\u8fdb\u884c\u5feb\u901f\u7684\u4ee3\u7801\u5b9e\u9a8c\u548c\u8c03\u8bd5\u3002<\/p>\n<\/p>\n<p><h2>\u4e03\u3001\u603b\u7ed3<\/h2>\n<\/p>\n<p><p>\u8c03\u8bd5\u662f\u7f16\u7a0b\u4e2d\u5fc5\u4e0d\u53ef\u5c11\u7684\u4e00\u90e8\u5206\u3002<strong>\u901a\u8fc7\u4f7f\u7528\u5408\u9002\u7684\u8c03\u8bd5\u5de5\u5177\u548c\u65b9\u6cd5\uff0c\u5982pdb\u8c03\u8bd5\u3001\u65e5\u5fd7\u8bb0\u5f55\u3001\u5f02\u5e38\u5904\u7406\u3001\u5355\u5143\u6d4b\u8bd5\u3001IDE\u8c03\u8bd5\u548c\u5728\u7ebf\u5de5\u5177\u7b49\uff0c\u4f60\u53ef\u4ee5\u66f4\u52a0\u9ad8\u6548\u5730\u5b9a\u4f4d\u548c\u89e3\u51b3\u7a0b\u5e8f\u4e2d\u7684\u95ee\u9898\u3002<\/strong>\u5728\u8c03\u8bd5\u8fc7\u7a0b\u4e2d\uff0c\u4fdd\u6301\u8010\u5fc3\u548c\u7ec6\u5fc3\uff0c\u9010\u6b65\u5206\u6790\u95ee\u9898\u7684\u6839\u6e90\uff0c\u624d\u80fd\u786e\u4fdd\u4ee3\u7801\u7684\u6b63\u786e\u6027\u548c\u7a33\u5b9a\u6027\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u6709\u6548\u4f7f\u7528\u8c03\u8bd5\u5de5\u5177\uff1f<\/strong><br \/>Python\u63d0\u4f9b\u4e86\u591a\u79cd\u8c03\u8bd5\u5de5\u5177\uff0c\u5982PDB\uff08Python Debugger\uff09\u3002\u901a\u8fc7\u547d\u4ee4\u884c\u53ef\u4ee5\u9010\u6b65\u6267\u884c\u4ee3\u7801\uff0c\u68c0\u67e5\u53d8\u91cf\u72b6\u6001\uff0c\u8bbe\u7f6e\u65ad\u70b9\u7b49\u3002\u60a8\u53ef\u4ee5\u5728\u4ee3\u7801\u4e2d\u63d2\u5165<code>import pdb; pdb.set_trace()<\/code>\u6765\u542f\u52a8\u8c03\u8bd5\u4f1a\u8bdd\uff0c\u5b9e\u65f6\u67e5\u770b\u7a0b\u5e8f\u8fd0\u884c\u60c5\u51b5\u3002<\/p>\n<p><strong>\u8c03\u8bd5Python\u4ee3\u7801\u65f6\u5e38\u89c1\u7684\u9519\u8bef\u6709\u54ea\u4e9b\uff1f<\/strong><br \/>\u5728\u8c03\u8bd5\u8fc7\u7a0b\u4e2d\uff0c\u5e38\u89c1\u7684\u9519\u8bef\u5305\u62ec\u53d8\u91cf\u672a\u5b9a\u4e49\u3001\u7d22\u5f15\u8d85\u51fa\u8303\u56f4\u3001\u7c7b\u578b\u9519\u8bef\u7b49\u3002\u901a\u8fc7\u4f7f\u7528\u8c03\u8bd5\u5de5\u5177\uff0c\u60a8\u53ef\u4ee5\u9010\u884c\u68c0\u67e5\u4ee3\u7801\uff0c\u786e\u4fdd\u6bcf\u4e2a\u53d8\u91cf\u7684\u503c\u548c\u7c7b\u578b\u90fd\u662f\u9884\u671f\u7684\u3002\u8fd9\u79cd\u65b9\u6cd5\u80fd\u591f\u5e2e\u52a9\u60a8\u5feb\u901f\u5b9a\u4f4d\u95ee\u9898\u3002<\/p>\n<p><strong>\u5982\u4f55\u63d0\u9ad8Python\u4ee3\u7801\u7684\u53ef\u8c03\u8bd5\u6027\uff1f<\/strong><br \/>\u7f16\u5199\u6e05\u6670\u4e14\u7ed3\u6784\u826f\u597d\u7684\u4ee3\u7801\u662f\u63d0\u9ad8\u53ef\u8c03\u8bd5\u6027\u7684\u5173\u952e\u3002\u826f\u597d\u7684\u547d\u540d\u89c4\u8303\u3001\u9002\u5f53\u7684\u6ce8\u91ca\u4ee5\u53ca\u5408\u7406\u7684\u51fd\u6570\u5212\u5206\u90fd\u4f1a\u4f7f\u8c03\u8bd5\u8fc7\u7a0b\u66f4\u52a0\u987a\u5229\u3002\u6b64\u5916\uff0c\u4f7f\u7528\u65e5\u5fd7\u8bb0\u5f55\u529f\u80fd\u53ef\u4ee5\u5e2e\u52a9\u60a8\u5728\u4ee3\u7801\u8fd0\u884c\u65f6\u8ffd\u8e2a\u95ee\u9898\uff0c\u907f\u514d\u4f7f\u7528<code>print<\/code>\u8bed\u53e5\u9020\u6210\u7684\u6df7\u4e71\u3002<\/p>\n<p><strong>\u5728\u8c03\u8bd5Python\u65f6\uff0c\u5982\u4f55\u6709\u6548\u7ba1\u7406\u590d\u6742\u7684\u4ee3\u7801\u903b\u8f91\uff1f<\/strong><br \/>\u5904\u7406\u590d\u6742\u7684\u4ee3\u7801\u903b\u8f91\u65f6\uff0c\u53ef\u4ee5\u8003\u8651\u4f7f\u7528\u8c03\u8bd5\u5668\u7684\u6761\u4ef6\u65ad\u70b9\u529f\u80fd\uff0c\u5b83\u5141\u8bb8\u60a8\u5728\u7279\u5b9a\u6761\u4ef6\u6ee1\u8db3\u65f6\u624d\u4e2d\u65ad\u4ee3\u7801\u6267\u884c\u3002\u8fd9\u79cd\u65b9\u6cd5\u53ef\u4ee5\u5e2e\u52a9\u60a8\u96c6\u4e2d\u5173\u6ce8\u7279\u5b9a\u90e8\u5206\u7684\u4ee3\u7801\uff0c\u907f\u514d\u5728\u5927\u91cf\u4e0d\u76f8\u5173\u4ee3\u7801\u4e2d\u8ff7\u5931\u65b9\u5411\u3002\u540c\u65f6\uff0c\u5229\u7528\u5355\u5143\u6d4b\u8bd5\u6846\u67b6\u53ef\u4ee5\u63d0\u524d\u6355\u83b7\u6f5c\u5728\u7684\u903b\u8f91\u9519\u8bef\uff0c\u4ece\u800c\u7b80\u5316\u8c03\u8bd5\u8fc7\u7a0b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5f00\u5934\u6bb5\u843d\uff1aPython\u8c03\u8bd5\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528\u5185\u7f6e\u7684\u8c03\u8bd5\u5de5\u5177\u3001\u65e5\u5fd7\u8bb0\u5f55\u3001\u65ad\u70b9\u548c\u5355\u6b65\u6267\u884c\u3001\u5f02\u5e38\u5904\u7406\u7b49\u65b9\u6cd5\u6765\u8fdb\u884c\u3002\u5176\u4e2d\uff0c\u4f7f [&hellip;]","protected":false},"author":3,"featured_media":935613,"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\/935609"}],"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=935609"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/935609\/revisions"}],"predecessor-version":[{"id":935614,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/935609\/revisions\/935614"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/935613"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=935609"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=935609"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=935609"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}