{"id":120905,"date":"2026-11-01T20:08:48","date_gmt":"2026-11-01T12:08:48","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/120905.html"},"modified":"2026-11-01T20:08:48","modified_gmt":"2026-11-01T12:08:48","slug":"%e6%8e%a5%e5%8f%a3%e9%93%be%e8%b7%af%e7%bc%96%e6%8e%92%ef%bc%9a%e5%8f%82%e6%95%b0%e5%85%b3%e8%81%94%e3%80%81%e4%be%9d%e8%b5%96%e4%b8%8e%e5%a4%b1%e8%b4%a5%e5%88%86%e6%94%af","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/120905.html","title":{"rendered":"\u63a5\u53e3\u94fe\u8def\u7f16\u6392\uff1a\u53c2\u6570\u5173\u8054\u3001\u4f9d\u8d56\u4e0e\u5931\u8d25\u5206\u652f"},"content":{"rendered":"<p>\u63a5\u53e3\u94fe\u8def\u91cc\u6700\u5bb9\u6613\u51fa\u9519\u7684\u4e09\u4e2a\u5730\u65b9&#xff0c;\u51fa\u95ee\u9898\u65f6\u901a\u5e38\u90fd\u4e0d\u62a5\u9519&#xff0c;\u53ea\u662f\u7ed3\u679c\u4e0d\u5bf9&#xff1a;\u503c\u4ece\u54ea\u6765\u3001\u5931\u8d25\u4e86\u600e\u4e48\u529e\u3001\u4ec0\u4e48\u7b97\u5bf9\u3002<\/p>\n<p>\u8fd9\u4e00\u7bc7\u628a\u4e09\u8005\u90fd\u53d8\u6210\u914d\u7f6e\u91cc\u7684\u663e\u5f0f\u7ea6\u5b9a\u3002<\/p>\n<p>\u914d\u5957\u811a\u672c\u5728 examples\/lab\/day33\/&#xff0c;\u56db\u4e2a\u6587\u4ef6\u90fd\u80fd\u76f4\u63a5\u8dd1\u3002\u4ee3\u7801\u5728 Windows\u3001Python 3.11 \u4e0b\u5b9e\u8dd1&#xff0c;pytest 3 passed\u3002<\/p>\n<h3>&#x1f517; \u4e00\u3001\u53c2\u6570\u5173\u8054&#xff1a;\u503c\u5230\u5e95\u4ece\u54ea\u6765<\/h3>\n<p>\u6bcf\u4e00\u6b65\u8981\u7528\u7684\u503c\u53ea\u6709\u4e09\u4e2a\u6765\u6e90&#xff1a;\u5199\u6b7b\u7684\u3001\u4e0a\u4e00\u6b65\u4ea7\u751f\u7684\u3001\u66f4\u65e9\u67d0\u4e00\u6b65\u4ea7\u751f\u7684\u3002<\/p>\n<p>\u5199\u6b7b\u7684\u95ee\u9898 Day31 \u8bb2\u8fc7\u2014\u2014\u6362\u73af\u5883\u5c31\u6ca1\u4e86\u3002<\/p>\n<p>\u7528\u914d\u7f6e\u5199\u51fa\u6765&#xff1a;<\/p>\n<p>\u94fe\u8def &#061; [<br \/>\n    {&#034;\u6b65\u9aa4&#034;: &#034;\u521b\u5efa\u8ba2\u5355&#034;, &#034;\u65b9\u6cd5&#034;: &#034;POST&#034;, &#034;\u8def\u5f84&#034;: &#034;\/orders&#034;,<br \/>\n     &#034;\u8bf7\u6c42\u4f53&#034;: {&#034;user_id&#034;: &#034;u1&#034;, &#034;amount&#034;: &#034;199.80&#034;},<br \/>\n     &#034;\u671f\u671b\u72b6\u6001\u7801&#034;: 201,<br \/>\n     &#034;\u4ea7\u751f&#034;: {&#034;order_id&#034;: &#034;\u54cd\u5e94.order_id&#034;}},<br \/>\n    {&#034;\u6b65\u9aa4&#034;: &#034;\u652f\u4ed8\u8ba2\u5355&#034;, &#034;\u65b9\u6cd5&#034;: &#034;POST&#034;, &#034;\u8def\u5f84&#034;: &#034;\/orders\/{order_id}\/pay&#034;,<br \/>\n     &#034;\u8bf7\u6c42\u4f53&#034;: {&#034;status&#034;: &#034;SUCCESS&#034;}, &#034;\u671f\u671b\u72b6\u6001\u7801&#034;: 200, &#034;\u4ea7\u751f&#034;: {}},<br \/>\n    {&#034;\u6b65\u9aa4&#034;: &#034;\u53d6\u6d88\u8ba2\u5355&#034;, &#034;\u65b9\u6cd5&#034;: &#034;POST&#034;, &#034;\u8def\u5f84&#034;: &#034;\/orders\/{order_id}\/cancel&#034;,<br \/>\n     &#034;\u8bf7\u6c42\u4f53&#034;: {}, &#034;\u671f\u671b\u72b6\u6001\u7801&#034;: 409, &#034;\u4ea7\u751f&#034;: {}},<br \/>\n    {&#034;\u6b65\u9aa4&#034;: &#034;\u67e5\u8ba2\u5355&#034;, &#034;\u65b9\u6cd5&#034;: &#034;GET&#034;, &#034;\u8def\u5f84&#034;: &#034;\/orders\/{order_id}&#034;,<br \/>\n     &#034;\u8bf7\u6c42\u4f53&#034;: None, &#034;\u671f\u671b\u72b6\u6001\u7801&#034;: 200, &#034;\u4ea7\u751f&#034;: {}},<br \/>\n]<\/p>\n<p>\u300c\u4ea7\u751f\u300d\u8fd9\u4e00\u680f\u5c31\u662f\u300c\u4e0a\u4e00\u6b65\u5582\u7ed9\u4e0b\u4e00\u6b65\u300d\u7684\u5168\u90e8\u542b\u4e49\u3002requests \u89c1\u5b98\u65b9\u5feb\u901f\u4e0a\u624b&#xff0c;pytest.raises \u89c1\u5b98\u65b9\u6587\u6863&#xff0c;JSON \u8bfb\u5199\u89c1 Python \u5b98\u65b9\u6587\u6863\u3002<\/p>\n<h4>\u6267\u884c\u5668<\/h4>\n<p>def \u53d6\u5b57\u6bb5(\u54cd\u5e94\u4f53, \u8def\u5f84\u4e32):<br \/>\n    &#034;&#034;&#034;\u4ece\u54cd\u5e94\u91cc\u6309 &#039;\u54cd\u5e94.order_id&#039; \u8fd9\u79cd\u5199\u6cd5\u53d6\u5b57\u6bb5\u3002&#034;&#034;&#034;<br \/>\n    if \u8def\u5f84\u4e32.startswith(&#034;\u54cd\u5e94.&#034;):<br \/>\n        \u8def\u5f84\u4e32 &#061; \u8def\u5f84\u4e32[len(&#034;\u54cd\u5e94.&#034;):]<br \/>\n    \u5f53\u524d &#061; \u54cd\u5e94\u4f53<br \/>\n    for \u4e00\u6bb5 in \u8def\u5f84\u4e32.split(&#034;.&#034;):<br \/>\n        if isinstance(\u5f53\u524d, dict) and \u4e00\u6bb5 in \u5f53\u524d:<br \/>\n            \u5f53\u524d &#061; \u5f53\u524d[\u4e00\u6bb5]<br \/>\n        else:<br \/>\n            raise KeyError(f&#034;\u54cd\u5e94\u91cc\u6ca1\u6709 {\u8def\u5f84\u4e32!r}&#xff0c;\u73b0\u6709&#xff1a;{\u5f53\u524d}&#034;)<br \/>\n    return \u5f53\u524d<\/p>\n<p>def \u8dd1\u94fe\u8def(base, \u6b65\u9aa4\u4eec, \u53d8\u91cf&#061;None):<br \/>\n    \u53d8\u91cf &#061; dict(\u53d8\u91cf or {})<br \/>\n    \u6bcf\u6b65\u7ed3\u679c &#061; []<\/p>\n<p>    for \u6b65\u9aa4 in \u6b65\u9aa4\u4eec:<br \/>\n        \u8def\u5f84 &#061; \u6b65\u9aa4[&#034;\u8def\u5f84&#034;]<br \/>\n        for \u540d\u5b57, \u503c in \u53d8\u91cf.items():<br \/>\n            \u8def\u5f84 &#061; \u8def\u5f84.replace(&#034;{&#034; &#043; \u540d\u5b57 &#043; &#034;}&#034;, str(\u503c))<br \/>\n        if &#034;{&#034; in \u8def\u5f84:<br \/>\n            raise ValueError(f&#034;\u6b65\u9aa4\u300c{\u6b65\u9aa4[&#039;\u6b65\u9aa4&#039;]}\u300d\u7684\u5730\u5740\u8fd8\u6709\u6ca1\u66ff\u6362\u7684\u53d8\u91cf&#xff1a;{\u8def\u5f84}&#034;)<\/p>\n<p>        if \u6b65\u9aa4[&#034;\u65b9\u6cd5&#034;] &#061;&#061; &#034;GET&#034;:<br \/>\n            \u54cd\u5e94 &#061; requests.get(f&#034;{base}{\u8def\u5f84}&#034;, timeout&#061;5)<br \/>\n        else:<br \/>\n            \u54cd\u5e94 &#061; requests.post(f&#034;{base}{\u8def\u5f84}&#034;, json&#061;\u6b65\u9aa4[&#034;\u8bf7\u6c42\u4f53&#034;], timeout&#061;5)<\/p>\n<p>        \u6bcf\u6b65\u7ed3\u679c.append({&#034;\u6b65\u9aa4&#034;: \u6b65\u9aa4[&#034;\u6b65\u9aa4&#034;], &#034;\u72b6\u6001\u7801&#034;: \u54cd\u5e94.status_code,<br \/>\n                     &#034;\u54cd\u5e94&#034;: \u54cd\u5e94.json()})<\/p>\n<p>        for \u53d8\u91cf\u540d, \u6765\u6e90 in \u6b65\u9aa4.get(&#034;\u4ea7\u751f&#034;, {}).items():<br \/>\n            \u53d8\u91cf[\u53d8\u91cf\u540d] &#061; \u53d6\u5b57\u6bb5(\u54cd\u5e94.json(), \u6765\u6e90)<\/p>\n<p>    return \u6bcf\u6b65\u7ed3\u679c, \u53d8\u91cf<\/p>\n<p>\u53d6\u5b57\u6bb5 \u91cc\u7684 raise KeyError \u4e0d\u80fd\u7701\u3002 \u5b57\u6bb5\u540d\u5199\u9519\u65f6\u5b83\u8981\u8bf4\u6e05\u695a\u300c\u54cd\u5e94\u91cc\u6ca1\u6709\u8fd9\u4e2a\u5b57\u6bb5&#xff0c;\u73b0\u6709\u7684\u662f\u4ec0\u4e48\u300d&#xff0c;\u800c\u4e0d\u662f\u629b\u4e00\u4e2a KeyError: &#039;order_id&#039; \u8ba9\u4eba\u81ea\u5df1\u731c\u3002<\/p>\n<h4>\u90a3\u4e2a\u68c0\u67e5\u7684\u4ef7\u503c<\/h4>\n<p>\u5047\u8bbe\u6709\u4eba\u6539\u4e86\u94fe\u8def&#xff0c;\u628a\u7b2c\u4e00\u6b65\u7684\u300c\u4ea7\u751f\u300d\u5220\u4e86&#xff1a;<\/p>\n<p>\u6b65\u9aa4\u300c\u652f\u4ed8\u8ba2\u5355\u300d\u7684\u5730\u5740\u8fd8\u6709\u6ca1\u66ff\u6362\u7684\u53d8\u91cf&#xff1a;\/orders\/{order_id}\/pay<\/p>\n<p>\u8fd9\u4e00\u6b65\u5c31\u70b8\u4e86&#xff0c;\u800c\u4e14\u8bf4\u5f97\u5f88\u6e05\u695a\u3002<\/p>\n<p>\u4e0d\u52a0\u68c0\u67e5\u7684\u8bdd&#xff0c;\u5b83\u4f1a\u53d1\u4e00\u4e2a\u5730\u5740\u91cc\u5e26\u7740 {order_id} \u7684\u8bf7\u6c42&#xff0c;\u670d\u52a1\u7aef\u8fd4\u56de 404&#xff0c;\u7136\u540e\u4f60\u5f97\u5148\u60f3\u5230\u300c\u54e6\u662f\u53d8\u91cf\u6ca1\u66ff\u6362\u300d\u3002<\/p>\n<p>\u8fd9\u4e2a\u68c0\u67e5\u628a\u300c\u731c\u300d\u53d8\u6210\u300c\u770b\u300d\u3002<\/p>\n<h3>&#x1f500; \u4e8c\u3001\u5931\u8d25\u5206\u652f&#xff1a;\u505c\u8fd8\u662f\u8df3\u8fc7<\/h3>\n<p>\u7528\u4e00\u6761\u4f1a\u5931\u8d25\u7684\u94fe\u8def&#xff1a;\u521b\u5efa \u2192 \u652f\u4ed8 \u2192 \u53d6\u6d88&#xff08;\u5df2\u652f\u4ed8&#xff0c;\u5fc5\u7136 409&#xff09; \u2192 \u67e5\u8ba2\u5355 \u2192 \u67e5\u652f\u4ed8\u8bb0\u5f55\u3002<\/p>\n<h4>\u7b56\u7565\u4e00&#xff1a;\u5931\u8d25\u5c31\u505c<\/h4>\n<p>def \u7b56\u7565_\u9047\u5230\u5931\u8d25\u5c31\u505c(base, \u6b65\u9aa4\u4eec, \u53d8\u91cf&#061;None):<br \/>\n    \u53d8\u91cf &#061; dict(\u53d8\u91cf or {})<br \/>\n    \u7ed3\u679c &#061; []<br \/>\n    for \u6b65\u9aa4 in \u6b65\u9aa4\u4eec:<br \/>\n        # &#8230; \u53d1\u8bf7\u6c42\u3001\u8bb0\u7ed3\u679c &#8230;<br \/>\n        if \u54cd\u5e94.status_code &gt;&#061; 400:<br \/>\n            \u7ed3\u679c[-1][&#034;\u5904\u7406&#034;] &#061; &#034;\u5931\u8d25&#xff0c;\u505c\u5728\u8fd9\u91cc&#034;<br \/>\n            return \u7ed3\u679c, \u53d8\u91cf, &#034;\u505c\u6b62&#034;     # \u76f4\u63a5\u7ed3\u675f\u6574\u6761\u94fe\u8def<br \/>\n    return \u7ed3\u679c, \u53d8\u91cf, &#034;\u5168\u90e8\u8dd1\u5b8c&#034;<\/p>\n<p>\u5b9e\u9645\u8dd1\u4e86 3 \u6b65&#xff0c;\u540e\u4e24\u6b65\u6ca1\u8dd1\u3002<\/p>\n<h4>\u7b56\u7565\u4e8c&#xff1a;\u5931\u8d25\u5c31\u8df3\u8fc7<\/h4>\n<p>if \u54cd\u5e94.status_code &gt;&#061; 400:<br \/>\n    \u7ed3\u679c[-1][&#034;\u5904\u7406&#034;] &#061; &#034;\u5931\u8d25&#xff0c;\u540e\u9762\u8df3\u8fc7&#034;<br \/>\n    \u8df3\u8fc7\u4e2d &#061; True<\/p>\n<p>\u4e94\u6b65\u5168\u8bb0\u4e0b\u6765\u4e86&#xff0c;\u4f46\u540e\u4e24\u6b65\u6ca1\u771f\u8dd1\u3002<\/p>\n<h4>\u600e\u4e48\u9009<\/h4>\n<p>\u5173\u952e\u95ee\u9898\u662f&#xff1a;\u540e\u9762\u7684\u6b65\u9aa4\u4f9d\u8d56\u524d\u9762\u5417&#xff1f;<\/p>\n<table>\n<tr>\u540e\u9762\u7684\u6b65\u9aa4\u4f9d\u8d56\u524d\u9762\u5417\u8be5\u600e\u4e48\u529e<\/tr>\n<tbody>\n<tr>\n<td>\u67e5\u8ba2\u5355<\/td>\n<td>\u4f9d\u8d56&#xff0c;\u53d6\u6d88\u5931\u8d25\u5b83\u5c31\u6ca1\u610f\u4e49<\/td>\n<td>\u505c<\/td>\n<\/tr>\n<tr>\n<td>\u67e5\u652f\u4ed8\u8bb0\u5f55<\/td>\n<td>\u4e0d\u4f9d\u8d56&#xff0c;\u53d6\u6d88\u5931\u8d25\u5b83\u8fd8\u80fd\u89e3\u91ca\u539f\u56e0<\/td>\n<td>\u7ee7\u7eed\u8dd1<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6240\u4ee5\u8fd9\u4e24\u6b65\u5176\u5b9e\u8be5\u5206\u5f00\u5904\u7406\u3002 \u300c\u5931\u8d25\u5c31\u505c\u300d\u662f\u5168\u5c40\u7b56\u7565&#xff0c;\u5b83\u592a\u7c97\u3002<\/p>\n<h4>\u6240\u4ee5\u6b63\u786e\u505a\u6cd5\u662f\u6309\u6b65\u5199<\/h4>\n<p>{<br \/>\n  &#034;\u6b65\u9aa4&#034;: &#034;\u67e5\u8ba2\u5355&#034;,<br \/>\n  &#034;\u65b9\u6cd5&#034;: &#034;GET&#034;,<br \/>\n  &#034;\u8def\u5f84&#034;: &#034;\/orders\/{order_id}&#034;,<br \/>\n  &#034;\u8bf7\u6c42\u4f53&#034;: null,<br \/>\n  &#034;\u671f\u671b\u72b6\u6001\u7801&#034;: 200,<br \/>\n  &#034;\u4f9d\u8d56&#034;: [&#034;\u521b\u5efa\u8ba2\u5355&#034;],<br \/>\n  &#034;\u4f9d\u8d56\u5931\u8d25\u65f6&#034;: &#034;\u8df3\u8fc7&#034;<br \/>\n}<\/p>\n<p>\u300c\u4f9d\u8d56\u5931\u8d25\u65f6\u300d\u8fd9\u4e00\u680f\u662f\u4eca\u5929\u7684\u91cd\u70b9&#xff1a;\u5199\u300c\u8df3\u8fc7\u300d\u8fd8\u662f\u300c\u505c\u6b62\u300d&#xff0c;\u53d6\u51b3\u4e8e\u8fd9\u4e00\u6b65\u8fd8\u503c\u4e0d\u503c\u5f97\u8dd1\u3002<\/p>\n<p>\u4f9d\u8d56\u5199\u6e05\u695a\u4e4b\u540e&#xff0c;\u8fd9\u4e2a\u5224\u65ad\u5c31\u4ece\u4eba\u7684\u8111\u5b50\u91cc\u642c\u5230\u4e86\u914d\u7f6e\u91cc\u3002<\/p>\n<h3>\u2705 \u4e09\u3001\u6bcf\u6b65\u5199\u6e05\u671f\u671b\u72b6\u6001\u7801<\/h3>\n<p>\u4e0a\u9762\u90a3\u6761\u94fe\u8def\u91cc\u7b2c\u4e09\u6b65\u8fd4\u56de 409\u3002\u8fd9\u662f\u5931\u8d25\u5417&#xff1f;<\/p>\n<p>\u4e0d\u662f\u3002\u300c\u53d6\u6d88\u5df2\u652f\u4ed8\u7684\u8ba2\u5355\u4f1a\u88ab\u62d2\u7edd\u300d\u6b63\u662f\u8fd9\u4e00\u6b65\u8981\u9a8c\u7684\u4e1c\u897f\u3002<\/p>\n<h4>\u4e3a\u4ec0\u4e48\u4e0d\u80fd\u5077\u61d2\u7528\u300c&gt;&#061; 400 \u5c31\u5f53\u5931\u8d25\u300d<\/h4>\n<p>\u56e0\u4e3a\u90a3\u6837\u7684\u8bdd&#xff0c;\u300c\u53d6\u6d88\u5df2\u652f\u4ed8\u8ba2\u5355\u5e94\u8be5\u88ab\u62d2\u7edd\u300d\u8fd9\u6761\u7528\u4f8b\u6c38\u8fdc\u8dd1\u4e0d\u8fc7\u3002<\/p>\n<p>\u8dd1\u4e0d\u8fc7&#xff0c;\u5927\u5bb6\u5c31\u4f1a\u4e60\u60ef\u6027\u5730\u5ffd\u7565 409\u2014\u2014\u7136\u540e\u771f\u6b63\u7684 409 \u4e5f\u88ab\u5ffd\u7565\u4e86\u3002<\/p>\n<p>\u8fd9\u662f\u63a5\u53e3\u6d4b\u8bd5\u91cc\u6700\u9690\u853d\u7684\u4e00\u79cd\u9ebb\u6728&#xff1a;\u4e00\u4e2a\u6c38\u8fdc\u7ea2\u7684\u65ad\u8a00&#xff0c;\u7b49\u4e8e\u6ca1\u6709\u65ad\u8a00\u3002<\/p>\n<p>\u6539\u6210\u300c\u548c\u8fd9\u4e00\u6b65\u81ea\u5df1\u5199\u7684\u671f\u671b\u6bd4\u300d&#xff1a;<\/p>\n<p>\u671f\u671b &#061; \u6b65\u9aa4.get(&#034;\u671f\u671b\u72b6\u6001\u7801&#034;)<br \/>\n\u5b9e\u9645 &#061; \u54cd\u5e94.status_code<br \/>\n\u7b26\u5408 &#061; (\u671f\u671b is None) or (\u5b9e\u9645 &#061;&#061; \u671f\u671b)<\/p>\n<p>if \u7b26\u5408:<br \/>\n    for \u53d8\u91cf\u540d, \u6765\u6e90 in \u6b65\u9aa4.get(&#034;\u4ea7\u751f&#034;, {}).items():<br \/>\n        \u53d8\u91cf[\u53d8\u91cf\u540d] &#061; \u54cd\u5e94.json()[\u6765\u6e90.replace(&#034;\u54cd\u5e94.&#034;, &#034;&#034;)]<br \/>\nelse:<br \/>\n    \u7ed3\u679c[-1][&#034;\u5904\u7406&#034;] &#061; &#034;\u4e0d\u7b26\u5408\u671f\u671b&#034;<br \/>\n    if \u5931\u8d25\u5c31\u505c:<br \/>\n        \u505c &#061; True<\/p>\n<p>\u5b9e\u8dd1&#xff1a;<\/p>\n<p>\u521b\u5efa\u8ba2\u5355             \u5b9e\u9645 201  \u671f\u671b 201  \u7b26\u5408<br \/>\n\u652f\u4ed8\u8ba2\u5355             \u5b9e\u9645 200  \u671f\u671b 200  \u7b26\u5408<br \/>\n\u53d6\u6d88\u5df2\u652f\u4ed8\u7684\u8ba2\u5355       \u5b9e\u9645 409  \u671f\u671b 409  \u7b26\u5408<br \/>\n\u67e5\u8ba2\u5355              \u5b9e\u9645 200  \u671f\u671b 200  \u7b26\u5408<\/p>\n<p>\u7b2c\u4e09\u6b65\u5b9e\u9645 409\u3001\u671f\u671b 409&#xff0c;\u5b83\u662f\u7eff\u7684\u3002<\/p>\n<h4>\u671f\u671b\u5199\u9519\u4e86\u4f1a\u600e\u6837<\/h4>\n<p>\u628a\u7b2c\u4e09\u6b65\u671f\u671b\u9519\u5199\u6210 200&#xff1a;<\/p>\n<p>\u521b\u5efa\u8ba2\u5355             \u5b9e\u9645 201  \u671f\u671b 201  \u7b26\u5408<br \/>\n\u652f\u4ed8\u8ba2\u5355             \u5b9e\u9645 200  \u671f\u671b 200  \u7b26\u5408<br \/>\n\u53d6\u6d88\u5df2\u652f\u4ed8\u7684\u8ba2\u5355       \u5b9e\u9645 409  \u671f\u671b 200  \u4e0d\u7b26\u5408 \u2190 \u6293\u5230\u4e86<br \/>\n\u67e5\u8ba2\u5355              \u5b9e\u9645 \u8df3\u8fc7  \u671f\u671b &#8211;    \u4e0d\u7b26\u5408 \u2190 \u6293\u5230\u4e86<\/p>\n<p>\u63a5\u53e3\u8fd4\u56de 409 \u662f\u6b63\u786e\u7684&#xff0c;\u4f46\u7528\u4f8b\u671f\u671b 200&#xff0c;\u6240\u4ee5\u7528\u4f8b\u7ea2\u4e86\u3002\u7ea2\u7684\u662f\u7528\u4f8b&#xff0c;\u4e0d\u662f\u63a5\u53e3\u3002<\/p>\n<h4>\u4e00\u4e2a\u5b9e\u73b0\u7ec6\u8282<\/h4>\n<p>\u8df3\u8fc7\u7684\u90a3\u4e00\u6b65\u5728\u7ed3\u679c\u91cc\u6ca1\u6709\u300c\u671f\u671b\u300d\u5b57\u6bb5&#xff08;\u5b83\u6839\u672c\u6ca1\u8dd1&#xff09;\u3002\u6240\u4ee5\u683c\u5f0f\u5316\u8f93\u51fa\u65f6\u8981\u7528 .get(&#034;\u671f\u671b&#034;, &#034;-&#034;)&#xff0c;\u522b\u76f4\u63a5\u4e0b\u6807\u2014\u2014\u5426\u5219\u8df3\u8fc7\u7684\u6b65\u9aa4\u4f1a\u8ba9\u6574\u4e2a\u62a5\u544a\u811a\u672c\u5d29\u6389\u3002<\/p>\n<h3>&#x1f501; \u4f9d\u8d56\u5173\u7cfb\u4e3a\u4ec0\u4e48\u5fc5\u987b\u5199\u8fdb\u914d\u7f6e<\/h3>\n<p>\u56e0\u4e3a\u300c\u8c01\u4f9d\u8d56\u8c01\u300d\u662f\u8111\u5b50\u91cc\u7684\u77e5\u8bc6&#xff0c;\u800c\u8111\u5b50\u91cc\u7684\u77e5\u8bc6\u4e0d\u4f1a\u88ab review\u3002<\/p>\n<p>{<br \/>\n  &#034;\u6b65\u9aa4&#034;: &#034;\u67e5\u8ba2\u5355&#034;,<br \/>\n  &#034;\u65b9\u6cd5&#034;: &#034;GET&#034;,<br \/>\n  &#034;\u8def\u5f84&#034;: &#034;\/orders\/{order_id}&#034;,<br \/>\n  &#034;\u8bf7\u6c42\u4f53&#034;: null,<br \/>\n  &#034;\u671f\u671b\u72b6\u6001\u7801&#034;: 200,<br \/>\n  &#034;\u4f9d\u8d56&#034;: [&#034;\u521b\u5efa\u8ba2\u5355&#034;],<br \/>\n  &#034;\u4f9d\u8d56\u5931\u8d25\u65f6&#034;: &#034;\u8df3\u8fc7&#034;<br \/>\n}<\/p>\n<p>\u6709\u4e86\u8fd9\u4e24\u884c&#xff1a;<\/p>\n<ul>\n<li>\u522b\u4eba\u63d2\u5165\u65b0\u6b65\u9aa4\u65f6&#xff0c;\u80fd\u770b\u51fa\u8fd9\u4e00\u6b65\u53d7\u4ec0\u4e48\u5f71\u54cd<\/li>\n<li>\u6267\u884c\u5668\u77e5\u9053\u54ea\u4e00\u6b65\u6302\u4e86\u8be5\u8df3\u8fc7\u54ea\u4e00\u6b65<\/li>\n<li>\u300c\u67e5\u652f\u4ed8\u8bb0\u5f55\u300d\u8fd9\u79cd\u4e0d\u4f9d\u8d56\u4efb\u4f55\u4e1c\u897f\u7684\u6b65\u9aa4&#xff0c;\u5199 \u4f9d\u8d56: []&#xff0c;\u5b83\u5c31\u6c38\u8fdc\u8dd1<\/li>\n<\/ul>\n<h4>\u4e00\u4e2a\u771f\u5b9e\u573a\u666f&#xff1a;\u94fe\u8def\u8dd1\u5230\u4e00\u534a\u65ad\u4e86<\/h4>\n<p>\u7ebf\u4e0a\u6392\u67e5\u5e38\u89c1\u8fd9\u4e2a\u9700\u6c42&#xff1a;\u300c\u8dd1\u5230\u7b2c 3 \u6b65\u5931\u8d25\u4e86&#xff0c;\u770b\u770b\u5f53\u65f6\u7684\u6570\u636e\u662f\u4ec0\u4e48\u6837\u300d\u3002<\/p>\n<p>\u5982\u679c\u94fe\u8def\u662f\u300c\u5931\u8d25\u5c31\u505c\u300d&#xff0c;\u4f60\u53ea\u6709\u524d 3 \u6b65\u7684\u4fe1\u606f\u3002 \u4f46\u7b2c 4\u30015 \u6b65\u7684\u6570\u636e\u53ef\u80fd\u624d\u662f\u5173\u952e\u2014\u2014\u7b2c 4 \u6b65\u662f\u300c\u67e5\u652f\u4ed8\u8bb0\u5f55\u300d&#xff0c;\u5b83\u80fd\u89e3\u91ca\u7b2c 3 \u6b65\u4e3a\u4ec0\u4e48\u5931\u8d25\u3002<\/p>\n<p>\u6240\u4ee5\u300c\u505c\u300d\u548c\u300c\u8df3\u8fc7\u300d\u4e0d\u662f\u4e8c\u9009\u4e00&#xff0c;\u8981\u6309\u6b65\u5199\u3002<\/p>\n<h3>&#x1f9e9; \u4e00\u4e2a\u5b9e\u73b0\u4e0a\u7684\u7ec6\u8282&#xff1a;\u53d8\u91cf\u8868\u7684\u4f20\u9012<\/h3>\n<p>def \u8dd1\u94fe\u8def(base, \u6b65\u9aa4\u4eec, \u53d8\u91cf&#061;None):<br \/>\n    \u53d8\u91cf &#061; dict(\u53d8\u91cf or {})<br \/>\n    &#8230;<br \/>\n    for \u53d8\u91cf\u540d, \u6765\u6e90 in \u6b65\u9aa4.get(&#034;\u4ea7\u751f&#034;, {}).items():<br \/>\n        \u53d8\u91cf[\u53d8\u91cf\u540d] &#061; \u53d6\u5b57\u6bb5(\u54cd\u5e94.json(), \u6765\u6e90)<br \/>\n    return \u6bcf\u6b65\u7ed3\u679c, \u53d8\u91cf<\/p>\n<p>\u53d8\u91cf\u8868\u662f\u94fe\u8def\u7684\u300c\u516c\u5171\u9ed1\u677f\u300d&#xff0c;\u6bcf\u4e00\u6b65\u90fd\u5f80\u91cc\u5199\u3001\u4e5f\u4ece\u91cc\u9762\u8bfb\u3002<\/p>\n<p>\u597d\u5904\u662f\u7b80\u5355&#xff0c;\u574f\u5904\u662f\u540d\u5b57\u4f1a\u649e\u3002\u5982\u679c\u4e24\u4e2a\u4e0d\u540c\u7684\u6b65\u9aa4\u90fd\u4ea7\u751f order_id&#xff0c;\u540e\u4e00\u4e2a\u4f1a\u8986\u76d6\u524d\u4e00\u4e2a\u3002<\/p>\n<p>\u6240\u4ee5\u53d8\u91cf\u540d\u6700\u597d\u5e26\u4e0a\u6765\u6e90&#xff1a;<\/p>\n<p>{<br \/>\n  &#034;\u4ea7\u751f&#034;: {&#034;\u521b\u5efa\u8ba2\u5355\u7684order_id&#034;: &#034;\u54cd\u5e94.order_id&#034;}<br \/>\n}<\/p>\n<p>\u4ee3\u4ef7\u662f\u8def\u5f84\u53d8\u957f\u4e86&#xff08;\/orders\/{\u521b\u5efa\u8ba2\u5355\u7684order_id}&#xff09;\u3002\u4e24\u79cd\u505a\u6cd5\u6211\u4e00\u822c\u9009\u540e\u8005\u2014\u2014\u53d8\u91cf\u649e\u540d\u662f\u90a3\u79cd\u300c\u8dd1\u4e00\u6b21\u6ca1\u4e8b\u3001\u8dd1\u5341\u6b21\u5076\u5c14\u9519\u4e00\u6b21\u300d\u7684\u95ee\u9898&#xff0c;\u6bd4\u8def\u5f84\u957f\u96be\u67e5\u5f97\u591a\u3002<\/p>\n<h3>&#x1f9ea; \u94fe\u8def\u672c\u8eab\u4e5f\u53ef\u4ee5\u88ab\u6d4b<\/h3>\n<p>def test_\u94fe\u8def\u7684\u6bcf\u4e00\u6b65\u90fd\u7b26\u5408\u671f\u671b(\u672c\u5730\u670d\u52a1):<br \/>\n    \u7ed3\u679c, \u53d8\u91cf &#061; \u8dd1\u94fe\u8def(\u672c\u5730\u670d\u52a1, \u94fe\u8def)<br \/>\n    assert all(r.get(&#034;\u7b26\u5408&#034;) for r in \u7ed3\u679c)<br \/>\n    assert \u53d8\u91cf[&#034;order_id&#034;] &#061;&#061; &#034;2001&#034;<\/p>\n<p>\u8fd9\u548c\u6d4b\u5355\u4e2a\u63a5\u53e3\u4e0d\u4e00\u6837\u3002 \u5355\u4e2a\u63a5\u53e3\u7684\u6d4b\u8bd5\u53ea\u770b\u90a3\u4e00\u6b21\u54cd\u5e94&#xff1b;\u94fe\u8def\u6d4b\u8bd5\u770b\u7684\u662f\u300c\u6574\u6761\u6d41\u7a0b\u8d70\u4e0b\u6765&#xff0c;\u6bcf\u4e00\u6b65\u7684\u524d\u63d0\u90fd\u6210\u7acb\u300d\u3002<\/p>\n<p>\u4e00\u4e2a\u5e38\u89c1 bug \u662f&#xff1a;\u7b2c\u4e00\u6b65\u9020\u7684\u6570\u636e\u88ab\u7b2c\u4e8c\u6b65\u6539\u574f\u4e86&#xff0c;\u4f46\u6bcf\u4e00\u6b65\u5355\u72ec\u770b\u90fd\u7eff\u3002 \u94fe\u8def\u6d4b\u8bd5\u80fd\u6293\u5230\u3002<\/p>\n<h3>&#x1f4cb; \u4e00\u4efd\u80fd\u76f4\u63a5\u6284\u7684\u94fe\u8def\u6a21\u677f<\/h3>\n<p>{<br \/>\n  &#034;\u6b65\u9aa4&#034;: &#034;\u67e5\u8ba2\u5355&#034;,<br \/>\n  &#034;\u65b9\u6cd5&#034;: &#034;GET&#034;,<br \/>\n  &#034;\u8def\u5f84&#034;: &#034;\/orders\/{order_id}&#034;,<br \/>\n  &#034;\u8bf7\u6c42\u4f53&#034;: null,<br \/>\n  &#034;\u671f\u671b\u72b6\u6001\u7801&#034;: 200,<br \/>\n  &#034;\u4f9d\u8d56&#034;: [&#034;\u521b\u5efa\u8ba2\u5355&#034;],<br \/>\n  &#034;\u4f9d\u8d56\u5931\u8d25\u65f6&#034;: &#034;\u8df3\u8fc7&#034;<br \/>\n}<\/p>\n<p>\u56db\u4e2a\u5b57\u6bb5\u4e00\u4e2a\u90fd\u4e0d\u80fd\u5c11&#xff1a;<\/p>\n<ul>\n<li>\u671f\u671b\u72b6\u6001\u7801 \u2014\u2014 \u4e0d\u5199\u5c31\u9000\u56de\u300c&gt;&#061; 400 \u5c31\u5f53\u5931\u8d25\u300d&#xff0c;\u90a3\u6761\u6c38\u8fdc\u7ea2\u7684\u7528\u4f8b\u5c31\u56de\u6765\u4e86<\/li>\n<li>\u4f9d\u8d56 \u2014\u2014 \u4f9d\u8d56\u54ea\u4e00\u6b65\u4ea7\u51fa\u7684\u53d8\u91cf<\/li>\n<li>\u4f9d\u8d56\u5931\u8d25\u65f6 \u2014\u2014 \u8df3\u8fc7\u8fd8\u662f\u505c\u6b62<\/li>\n<li>\u65b9\u6cd5 \/ \u8def\u5f84 \/ \u8bf7\u6c42\u4f53 \u2014\u2014 \u8bf7\u6c42\u672c\u8eab<\/li>\n<\/ul>\n<p>\u300c\u4f9d\u8d56\u5931\u8d25\u65f6\u300d\u5199\u300c\u8df3\u8fc7\u300d\u8fd8\u662f\u300c\u505c\u6b62\u300d&#xff0c;\u53d6\u51b3\u4e8e\u8fd9\u4e00\u6b65\u8fd8\u503c\u4e0d\u503c\u5f97\u8dd1\u3002<\/p>\n<h4>\u649e\u540d\u5177\u4f53\u662f\u600e\u4e48\u53d1\u751f\u7684<\/h4>\n<p>\u53d8\u91cf\u8868\u5c31\u662f\u4e00\u4e2a\u666e\u901a\u5b57\u5178&#xff0c;\u952e\u662f\u53d8\u91cf\u540d&#xff0c;\u503c\u662f\u5185\u5bb9&#xff1a;<\/p>\n<p>\u53d8\u91cf &#061; {}<br \/>\n\u53d8\u91cf[&#034;order_id&#034;] &#061; &#034;2001&#034;     # \u7b2c\u4e00\u6b65\u5199\u5165<br \/>\n\u53d8\u91cf[&#034;order_id&#034;] &#061; &#034;2002&#034;     # \u7b2c\u4e8c\u6b65\u53c8\u5199\u4e86\u4e00\u4e2a&#xff0c;\u76f4\u63a5\u628a\u4e0a\u4e00\u4e2a\u9876\u6389<br \/>\nprint(\u53d8\u91cf)                    # {&#039;order_id&#039;: &#039;2002&#039;}<\/p>\n<p>\u6ca1\u6709\u4efb\u4f55\u8b66\u544a\u3002 \u7b2c\u4e00\u6b65\u4ea7\u51fa\u7684 2001 \u5c31\u8fd9\u4e48\u6ca1\u4e86&#xff0c;\u800c\u771f\u6b63\u9700\u8981\u5b83\u7684\u7b2c\u4e09\u6b65\u4f1a\u62ff\u5230 2002\u2014\u2014\u7136\u540e\u62ff\u7740\u4e00\u4e2a\u4e0d\u5b58\u5728\u7684\u8ba2\u5355\u53f7\u53bb\u67e5&#xff0c;\u63a5\u53e3\u56de 404&#xff0c;\u4f60\u5374\u4e0d\u77e5\u9053\u4e3a\u4ec0\u4e48\u3002<\/p>\n<p>\u6240\u4ee5\u8fd9\u6761\u89c4\u77e9\u4e0d\u662f\u300c\u597d\u770b\u300d&#xff0c;\u662f\u9632\u6b62\u4e00\u4e2a\u9759\u9ed8\u7684\u8986\u76d6\u3002<\/p>\n<h3>&#x1f501; \u4e00\u4e2a\u5bb9\u6613\u88ab\u5ffd\u7565\u7684\u89c4\u77e9<\/h3>\n<p>\u53d8\u91cf\u540d\u8981\u80fd\u770b\u51fa\u5b83\u4ece\u54ea\u6765\u3002<\/p>\n<p>\u53d8\u91cf\u8868\u662f\u94fe\u8def\u7684\u516c\u5171\u9ed1\u677f&#xff0c;\u4e24\u4e2a\u6b65\u9aa4\u90fd\u4ea7\u751f order_id \u5c31\u4f1a\u649e\u540d\u3002\u800c\u649e\u540d\u8fd9\u79cd bug \u4e0d\u662f\u5fc5\u73b0\u7684\u2014\u2014\u53d6\u51b3\u4e8e\u6b65\u9aa4\u8dd1\u5230\u54ea\u3001\u6267\u884c\u987a\u5e8f\u3001\u5f53\u65f6\u8868\u91cc\u6709\u4ec0\u4e48\u3002<\/p>\n<p>\u6240\u4ee5\u53d8\u91cf\u540d\u5e26\u4e0a\u6765\u6e90&#xff1a;<\/p>\n<p>{<br \/>\n  &#034;\u4ea7\u751f&#034;: {&#034;\u521b\u5efa\u8ba2\u5355\u7684order_id&#034;: &#034;\u54cd\u5e94.order_id&#034;}<br \/>\n}<\/p>\n<p>\u8def\u5f84\u53d8\u957f\u4e86&#xff0c;\u4f46\u53d8\u91cf\u649e\u540d\u662f\u90a3\u79cd\u300c\u8dd1\u4e00\u6b21\u6ca1\u4e8b\u3001\u8dd1\u5341\u6b21\u5076\u5c14\u9519\u4e00\u6b21\u300d\u7684\u95ee\u9898&#xff0c;\u6bd4\u8def\u5f84\u957f\u96be\u67e5\u5f97\u591a\u3002<\/p>\n<h3>&#x1f50d; \u4e00\u4e2a\u80fd\u7acb\u523b\u7528\u8d77\u6765\u7684\u52a8\u4f5c<\/h3>\n<p>\u62ff\u4f60\u624b\u4e0a\u4efb\u610f\u4e00\u6761\u94fe\u8def&#xff0c;\u628a\u8fd9\u4e09\u5904\u8865\u4e0a&#xff1a;<\/p>\n<li>\u6bcf\u4e00\u6b65\u52a0\u300c\u671f\u671b\u72b6\u6001\u7801\u300d<\/li>\n<li>\u6bcf\u4e00\u6b65\u52a0\u300c\u4f9d\u8d56\u300d\u548c\u300c\u4f9d\u8d56\u5931\u8d25\u65f6\u300d<\/li>\n<li>\u628a\u5199\u6b7b\u7684\u7f16\u53f7\u6539\u6210\u4e0a\u4e00\u6b65\u4ea7\u751f\u7684<\/li>\n<p>\u6539\u5b8c\u4f60\u4f1a\u53d1\u73b0&#xff0c;\u94fe\u8def\u91cc\u90a3\u4e9b\u300c\u6211\u8bb0\u5f97\u5b83\u5e94\u8be5\u5931\u8d25\u300d\u7684\u5730\u65b9&#xff0c;\u7ec8\u4e8e\u5199\u4e0b\u6765\u4e86\u3002<\/p>\n<p>\u800c\u8fd9\u4e9b\u539f\u672c\u90fd\u85cf\u5728\u67d0\u4e2a\u4eba\u8111\u5b50\u91cc&#xff0c;\u6216\u8005\u85cf\u5728\u67d0\u4e2a\u4eba\u7684\u8bb0\u6027\u91cc\u3002\u663e\u5f0f\u7ea6\u5b9a\u624d\u80fd\u88ab review&#xff0c;\u8111\u5b50\u91cc\u7684\u4e0d\u80fd\u3002<\/p>\n<h3>&#x1f4dd; \u4e09\u4e2a\u7ec3\u4e60<\/h3>\n<p>\u7b54\u6848\u5728 04_answer.py&#xff0c;9 \u6761\u65ad\u8a00&#xff0c;pytest 3 passed\u3002<\/p>\n<p>\u7ec3\u4e60\u4e00&#xff1a;\u53d8\u91cf\u4f20\u4e0b\u53bb\u3002\u53d8\u91cf &#061;&#061; {&#034;order_id&#034;: &#034;2001&#034;}&#xff0c;\u4e14\u7b2c 2\u30013\u30014 \u6b65\u7528\u7684\u90fd\u662f\u540c\u4e00\u4e2a\u53f7\u3002<\/p>\n<p>\u7ec3\u4e60\u4e8c&#xff1a;\u671f\u671b 409 \u662f\u7eff\u7684\u3002\u7b2c\u4e09\u6b65\u5b9e\u9645 409\u3001\u671f\u671b 409\u3001\u5224\u5b9a\u7b26\u5408&#xff0c;\u4e14\u5168\u90e8\u6b65\u9aa4\u90fd\u7b26\u5408\u3002<\/p>\n<p>\u7ec3\u4e60\u4e09&#xff1a;\u671f\u671b\u5199\u9519\u65f6\u7ea2\u7684\u662f\u7528\u4f8b\u3002\u63a5\u53e3\u4ecd\u8fd4\u56de 409&#xff08;\u5bf9\u7684&#xff09;&#xff0c;\u4f46\u7528\u4f8b\u671f\u671b 200&#xff0c;\u5224\u4e0d\u7b26\u5408\u3002<\/p>\n<h3>&#x1f4cc; \u4eca\u5929\u5e26\u8d70\u7684\u5224\u65ad\u89c4\u5219<\/h3>\n<p>\u4e09\u6837\u90fd\u5199\u6210\u914d\u7f6e\u91cc\u7684\u663e\u5f0f\u7ea6\u5b9a&#xff1a;\u503c\u4ece\u54ea\u6765\u3001\u5931\u8d25\u4e86\u600e\u4e48\u529e\u3001\u4ec0\u4e48\u7b97\u5bf9\u3002<\/p>\n<p>\u7406\u7531\u4e0d\u662f\u300c\u914d\u7f6e\u6bd4\u4ee3\u7801\u597d\u770b\u300d&#xff0c;\u800c\u662f\u8fd9\u4e09\u6837\u51fa\u95ee\u9898\u65f6\u901a\u5e38\u4e0d\u62a5\u9519\u3002\u9690\u542b\u7ea6\u5b9a\u53ea\u5728\u5199\u4ee3\u7801\u7684\u4eba\u8111\u5b50\u91cc&#xff0c;\u663e\u5f0f\u7ea6\u5b9a\u624d\u80fd\u88ab review\u3002<\/p>\n<h3>&#x1f6a7; \u4eca\u5929\u6ca1\u505a\u7684<\/h3>\n<ul>\n<li>\u6ca1\u6709\u505a\u771f\u6b63\u7684\u4f9d\u8d56\u56fe\u6392\u5e8f\u3002 \u4eca\u5929\u9760\u914d\u7f6e\u91cc\u7684\u987a\u5e8f\u8868\u8fbe\u4f9d\u8d56&#xff0c;\u6ca1\u505a\u62d3\u6251\u6392\u5e8f<\/li>\n<li>\u6ca1\u6709\u505a\u91cd\u8bd5\u3002 \u5931\u8d25\u540e\u91cd\u8bd5\u51e0\u6b21\u3001\u9000\u907f\u591a\u4e45&#xff0c;\u662f\u53e6\u4e00\u4e2a\u51b3\u5b9a<\/li>\n<li>\u6ca1\u6709\u505a\u5e76\u53d1\u94fe\u8def\u3002 \u6b65\u9aa4\u4e4b\u95f4\u5e76\u53d1\u6267\u884c&#xff0c;\u9700\u8981\u5904\u7406\u53d8\u91cf\u51b2\u7a81<\/li>\n<li>\u6ca1\u6709\u505a\u94fe\u8def\u7684\u65ad\u8a00\u3002 \u4eca\u5929\u65ad\u8a00\u7684\u662f\u6bcf\u4e00\u6b65\u7684\u54cd\u5e94&#xff0c;\u6574\u6761\u94fe\u8def\u7684\u7ed3\u8bba&#xff08;\u4e1a\u52a1\u4e0a\u6210\u529f\u4e86\u5417&#xff09;\u6ca1\u5355\u72ec\u9a8c<\/li>\n<\/ul>\n<p>\u4e0b\u4e00\u6b65\u662f Day34\u300a\u63a5\u53e3\u4efb\u52a1\u6267\u884c&#xff1a;\u72b6\u6001\u6d41\u8f6c\u3001\u53d6\u6d88\u4e0e\u7ed3\u679c\u4fdd\u5b58\u300b&#xff0c;\u6211\u4eec\u8dd1\u90a3\u79cd\u300c\u53d1\u51fa\u53bb\u5c31\u4e0d\u7528\u7ba1\u4e86\u300d\u7684\u4efb\u52a1\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u63a5\u53e3\u94fe\u8def\u91cc\u6700\u5bb9\u6613\u51fa\u9519\u7684\u4e09\u4e2a\u5730\u65b9&#xff0c;\u51fa\u95ee\u9898\u65f6\u901a\u5e38\u90fd\u4e0d\u62a5\u9519&#xff0c;\u53ea\u662f\u7ed3\u679c\u4e0d\u5bf9&#xff1a;\u503c\u4ece\u54ea\u6765\u3001\u5931\u8d25\u4e86\u600e\u4e48\u529e\u3001\u4ec0\u4e48\u7b97\u5bf9\u3002<br \/>\n\u8fd9\u4e00\u7bc7\u628a\u4e09\u8005\u90fd\u53d8\u6210\u914d\u7f6e\u91cc\u7684\u663e\u5f0f\u7ea6\u5b9a\u3002 \u914d\u5957\u811a\u672c\u5728 examples\/lab\/day33\/&#xff0c;\u56db\u4e2a\u6587\u4ef6\u90fd\u80fd\u76f4\u63a5\u8dd1\u3002\u4ee3\u7801\u5728 Windows\u3001Python 3.11 \u4e0b\u5b9e\u8dd1&#xff0c;pytest 3 passed\u3002 &#x1f517; \u4e00\u3001\u53c2\u6570\u5173\u8054&#xff1a;\u503c\u5230\u5e95\u4ece\u54ea\u6765<br \/>\n\u6bcf\u4e00\u6b65\u8981\u7528\u7684\u503c\u53ea\u6709\u4e09\u4e2a\u6765\u6e90&amp;#xff1a<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[81,50,139,137,210],"topic":[],"class_list":["post-120905","post","type-post","status-publish","format-standard","hentry","category-server","tag-python","tag-50","tag-139","tag-137","tag-210"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u63a5\u53e3\u94fe\u8def\u7f16\u6392\uff1a\u53c2\u6570\u5173\u8054\u3001\u4f9d\u8d56\u4e0e\u5931\u8d25\u5206\u652f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/120905.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u63a5\u53e3\u94fe\u8def\u7f16\u6392\uff1a\u53c2\u6570\u5173\u8054\u3001\u4f9d\u8d56\u4e0e\u5931\u8d25\u5206\u652f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u63a5\u53e3\u94fe\u8def\u91cc\u6700\u5bb9\u6613\u51fa\u9519\u7684\u4e09\u4e2a\u5730\u65b9&#xff0c;\u51fa\u95ee\u9898\u65f6\u901a\u5e38\u90fd\u4e0d\u62a5\u9519&#xff0c;\u53ea\u662f\u7ed3\u679c\u4e0d\u5bf9&#xff1a;\u503c\u4ece\u54ea\u6765\u3001\u5931\u8d25\u4e86\u600e\u4e48\u529e\u3001\u4ec0\u4e48\u7b97\u5bf9\u3002 \u8fd9\u4e00\u7bc7\u628a\u4e09\u8005\u90fd\u53d8\u6210\u914d\u7f6e\u91cc\u7684\u663e\u5f0f\u7ea6\u5b9a\u3002 \u914d\u5957\u811a\u672c\u5728 examples\/lab\/day33\/&#xff0c;\u56db\u4e2a\u6587\u4ef6\u90fd\u80fd\u76f4\u63a5\u8dd1\u3002\u4ee3\u7801\u5728 Windows\u3001Python 3.11 \u4e0b\u5b9e\u8dd1&#xff0c;pytest 3 passed\u3002 &#x1f517; \u4e00\u3001\u53c2\u6570\u5173\u8054&#xff1a;\u503c\u5230\u5e95\u4ece\u54ea\u6765 \u6bcf\u4e00\u6b65\u8981\u7528\u7684\u503c\u53ea\u6709\u4e09\u4e2a\u6765\u6e90&amp;#xff1a\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/120905.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-11-01T12:08:48+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/120905.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/120905.html\",\"name\":\"\u63a5\u53e3\u94fe\u8def\u7f16\u6392\uff1a\u53c2\u6570\u5173\u8054\u3001\u4f9d\u8d56\u4e0e\u5931\u8d25\u5206\u652f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-11-01T12:08:48+00:00\",\"dateModified\":\"2026-11-01T12:08:48+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/120905.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/120905.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/120905.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u63a5\u53e3\u94fe\u8def\u7f16\u6392\uff1a\u53c2\u6570\u5173\u8054\u3001\u4f9d\u8d56\u4e0e\u5931\u8d25\u5206\u652f\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u63a5\u53e3\u94fe\u8def\u7f16\u6392\uff1a\u53c2\u6570\u5173\u8054\u3001\u4f9d\u8d56\u4e0e\u5931\u8d25\u5206\u652f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/120905.html","og_locale":"zh_CN","og_type":"article","og_title":"\u63a5\u53e3\u94fe\u8def\u7f16\u6392\uff1a\u53c2\u6570\u5173\u8054\u3001\u4f9d\u8d56\u4e0e\u5931\u8d25\u5206\u652f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u63a5\u53e3\u94fe\u8def\u91cc\u6700\u5bb9\u6613\u51fa\u9519\u7684\u4e09\u4e2a\u5730\u65b9&#xff0c;\u51fa\u95ee\u9898\u65f6\u901a\u5e38\u90fd\u4e0d\u62a5\u9519&#xff0c;\u53ea\u662f\u7ed3\u679c\u4e0d\u5bf9&#xff1a;\u503c\u4ece\u54ea\u6765\u3001\u5931\u8d25\u4e86\u600e\u4e48\u529e\u3001\u4ec0\u4e48\u7b97\u5bf9\u3002 \u8fd9\u4e00\u7bc7\u628a\u4e09\u8005\u90fd\u53d8\u6210\u914d\u7f6e\u91cc\u7684\u663e\u5f0f\u7ea6\u5b9a\u3002 \u914d\u5957\u811a\u672c\u5728 examples\/lab\/day33\/&#xff0c;\u56db\u4e2a\u6587\u4ef6\u90fd\u80fd\u76f4\u63a5\u8dd1\u3002\u4ee3\u7801\u5728 Windows\u3001Python 3.11 \u4e0b\u5b9e\u8dd1&#xff0c;pytest 3 passed\u3002 &#x1f517; \u4e00\u3001\u53c2\u6570\u5173\u8054&#xff1a;\u503c\u5230\u5e95\u4ece\u54ea\u6765 \u6bcf\u4e00\u6b65\u8981\u7528\u7684\u503c\u53ea\u6709\u4e09\u4e2a\u6765\u6e90&amp;#xff1a","og_url":"https:\/\/www.wsisp.com\/helps\/120905.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-11-01T12:08:48+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/120905.html","url":"https:\/\/www.wsisp.com\/helps\/120905.html","name":"\u63a5\u53e3\u94fe\u8def\u7f16\u6392\uff1a\u53c2\u6570\u5173\u8054\u3001\u4f9d\u8d56\u4e0e\u5931\u8d25\u5206\u652f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-11-01T12:08:48+00:00","dateModified":"2026-11-01T12:08:48+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/120905.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/120905.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/120905.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u63a5\u53e3\u94fe\u8def\u7f16\u6392\uff1a\u53c2\u6570\u5173\u8054\u3001\u4f9d\u8d56\u4e0e\u5931\u8d25\u5206\u652f"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/120905","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=120905"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/120905\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=120905"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=120905"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=120905"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=120905"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}