$ python -m pdb my_script.py\n<\/code><\/pre>\n\n\n\n\u8fd9\u4f1a\u89e6\u53d1debugger\u5728\u811a\u672c\u7b2c\u4e00\u884c\u6307\u4ee4\u5904\u505c\u6b62\u6267\u884c\u3002\u8fd9\u5728\u811a\u672c\u5f88\u77ed\u65f6\u4f1a\u5f88\u6709\u5e2e\u52a9\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7(Pdb)\u6a21\u5f0f\u63a5\u7740\u67e5\u770b\u53d8\u91cf\u4fe1\u606f\uff0c\u5e76\u4e14\u9010\u884c\u8c03\u8bd5\u3002<\/p>\n\n\n\n
\u4ece\u811a\u672c\u5185\u90e8\u8fd0\u884c<\/h3>\n\n\n\n
\u540c\u65f6\uff0c\u4f60\u4e5f\u53ef\u4ee5\u5728\u811a\u672c\u5185\u90e8\u8bbe\u7f6e\u65ad\u70b9\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u5728\u67d0\u4e9b\u7279\u5b9a\u70b9\u67e5\u770b\u53d8\u91cf\u4fe1\u606f\u548c\u5404\u79cd\u6267\u884c\u65f6\u4fe1\u606f\u4e86\u3002\u8fd9\u91cc\u5c06\u4f7f\u7528pdb.set_trace()<\/code>\u65b9\u6cd5\u6765\u5b9e\u73b0\u3002\u4e3e\u4e2a\u4f8b\u5b50\uff1a<\/p>\n\n\n\nimport pdb\n\ndef make_bread():\n pdb.set_trace()\n return \"I don't have time\"\n\nprint(make_bread())\n<\/code><\/pre>\n\n\n\n\u8bd5\u4e0b\u4fdd\u5b58\u4e0a\u9762\u7684\u811a\u672c\u540e\u8fd0\u884c\u4e4b\u3002\u4f60\u4f1a\u5728\u8fd0\u884c\u65f6\u9a6c\u4e0a\u8fdb\u5165debugger\u6a21\u5f0f\u3002\u73b0\u5728\u662f\u65f6\u5019\u4e86\u89e3\u4e0bdebugger\u6a21\u5f0f\u4e0b\u7684\u4e00\u4e9b\u547d\u4ee4\u4e86\u3002<\/p>\n\n\n\n
\u547d\u4ee4\u5217\u8868\uff1a<\/h5>\n\n\n\nc<\/code>: \u7ee7\u7eed\u6267\u884c<\/li>w<\/code>: \u663e\u793a\u5f53\u524d\u6b63\u5728\u6267\u884c\u7684\u4ee3\u7801\u884c\u7684\u4e0a\u4e0b\u6587\u4fe1\u606f<\/li>a<\/code>: \u6253\u5370\u5f53\u524d\u51fd\u6570\u7684\u53c2\u6570\u5217\u8868<\/li>s<\/code>: \u6267\u884c\u5f53\u524d\u4ee3\u7801\u884c\uff0c\u5e76\u505c\u5728\u7b2c\u4e00\u4e2a\u80fd\u505c\u7684\u5730\u65b9\uff08\u76f8\u5f53\u4e8e\u5355\u6b65\u8fdb\u5165\uff09<\/li>n<\/code>: \u7ee7\u7eed\u6267\u884c\u5230\u5f53\u524d\u51fd\u6570\u7684\u4e0b\u4e00\u884c\uff0c\u6216\u8005\u5f53\u524d\u884c\u76f4\u63a5\u8fd4\u56de\uff08\u5355\u6b65\u8df3\u8fc7\uff09<\/li><\/ul>\n\n\n\n\u5355\u6b65\u8df3\u8fc7\uff08n<\/code>ext\uff09\u548c\u5355\u6b65\u8fdb\u5165\uff08s<\/code>tep\uff09\u7684\u533a\u522b\u5728\u4e8e\uff0c \u5355\u6b65\u8fdb\u5165\u4f1a\u8fdb\u5165\u5f53\u524d\u884c\u8c03\u7528\u7684\u51fd\u6570\u5185\u90e8\u5e76\u505c\u5728\u91cc\u9762\uff0c \u800c\u5355\u6b65\u8df3\u8fc7\u4f1a\uff08\u51e0\u4e4e\uff09\u5168\u901f\u6267\u884c\u5b8c\u5f53\u524d\u884c\u8c03\u7528\u7684\u51fd\u6570\uff0c\u5e76\u505c\u5728\u5f53\u524d\u51fd\u6570\u7684\u4e0b\u4e00\u884c\u3002<\/p>\n\n\n\npdb\u771f\u7684\u662f\u4e00\u4e2a\u5f88\u65b9\u4fbf\u7684\u529f\u80fd\uff0c\u4e0a\u9762\u4ec5\u5217\u4e3e\u5c11\u91cf\u7528\u6cd5\uff0c\u66f4\u591a\u7684\u547d\u4ee4\u5f3a\u70c8\u63a8\u8350\u4f60\u53bb\u770b\u5b98\u65b9\u6587\u6863\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"
\u8c03\u8bd5\uff08Debugging\uff09 \u5229\u7528\u597d\u8c03\u8bd5\uff0c\u80fd\u5927\u5927\u63d0\u9ad8\u4f60\u6355\u6349\u4ee3\u7801Bug\u7684\u3002\u5927\u90e8\u5206\u65b0\u4eba\u5ffd\u7565\u4e86Python debug<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17,13],"tags":[],"yoast_head":"\n
2.0 \u8c03\u8bd5 Debugging - Linux\u81ea\u52a8\u5316\u8fd0\u7ef4<\/title>\n\n\n\n\n\n\n\n\n\n\n\n\n