{"id":95544,"date":"2026-08-26T14:48:29","date_gmt":"2026-08-26T06:48:29","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/95544.html"},"modified":"2026-08-26T14:48:29","modified_gmt":"2026-08-26T06:48:29","slug":"%e7%b1%bb%e5%8f%98%e9%87%8f%e4%b8%8e%e5%ae%9e%e4%be%8b%e5%8f%98%e9%87%8f%ef%bc%9a%e4%b8%80%e4%b8%aa%e5%85%b1%e4%ba%ab%e5%88%97%e8%a1%a8%e5%bc%95%e5%8f%91%e7%9a%84%e7%ba%bf%e4%b8%8a%e4%ba%8b%e6%95%85","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/95544.html","title":{"rendered":"\u7c7b\u53d8\u91cf\u4e0e\u5b9e\u4f8b\u53d8\u91cf\uff1a\u4e00\u4e2a\u5171\u4eab\u5217\u8868\u5f15\u53d1\u7684\u7ebf\u4e0a\u4e8b\u6545"},"content":{"rendered":"<p>\u300cPython \u8fdb\u9636\u4e4b\u8def\u300d\u7cfb\u5217 Day11<\/p>\n<h3>\u5199\u5728\u524d\u9762<\/h3>\n<p>\u6a21\u5757\u4e8c\u51fd\u6570\u5f0f\u7f16\u7a0b\u7cfb\u5217\u5199\u5b8c&#xff0c;\u4eca\u5929\u5f00\u59cb\u6a21\u5757\u4e09\u9762\u5411\u5bf9\u8c61\u8fdb\u9636\u3002\u7b2c\u4e00\u7bc7\u8bb2\u4e00\u4e2a\u770b\u8d77\u6765\u5f88\u57fa\u7840\u3001\u4f46\u51e0\u4e4e\u4eba\u4eba\u90fd\u8e29\u8fc7\u7684\u5751&#xff1a;\u7c7b\u53d8\u91cf\u548c\u5b9e\u4f8b\u53d8\u91cf\u5206\u4e0d\u6e05\u695a&#xff0c;\u5c24\u5176\u662f\u7528\u53ef\u53d8\u7c7b\u578b&#xff08;list\/dict&#xff09;\u5f53\u7c7b\u53d8\u91cf\u65f6&#xff0c;\u672c\u610f\u662f&#034;\u6bcf\u4e2a\u5b9e\u4f8b\u4e00\u4efd\u72ec\u7acb\u6570\u636e&#034;&#xff0c;\u7ed3\u679c\u5374\u662f\u6240\u6709\u5b9e\u4f8b\u5171\u4eab\u540c\u4e00\u4efd\u2014\u2014\u8fd9\u8ddf Day01 \u8bb2\u7684\u53ef\u53d8\u9ed8\u8ba4\u53c2\u6570\u9677\u9631\u5176\u5b9e\u662f\u540c\u4e00\u7c7b\u95ee\u9898\u7684\u4e24\u79cd\u53d8\u4f53\u3002<\/p>\n<hr \/>\n<h3>\u4e00\u3001\u662f\u4ec0\u4e48&#xff1a;\u4e24\u79cd\u5c5e\u6027&#xff0c;\u4e24\u79cd\u5f52\u5c5e<\/h3>\n<ul>\n<li>\u7c7b\u53d8\u91cf&#xff08;class variable&#xff09;&#xff1a;\u76f4\u63a5\u5199\u5728\u7c7b\u4f53\u5185\u3001__init__ \u4e4b\u5916\u7684\u5c5e\u6027&#xff0c;\u5f52\u7c7b\u672c\u8eab\u6240\u6709&#xff0c;\u6240\u6709\u5b9e\u4f8b\u5171\u4eab\u540c\u4e00\u4efd\u6570\u636e<\/li>\n<li>\u5b9e\u4f8b\u53d8\u91cf&#xff08;instance variable&#xff09;&#xff1a;\u5728 __init__&#xff08;\u6216\u5176\u4ed6\u65b9\u6cd5&#xff09;\u91cc\u901a\u8fc7 self.attr &#061; &#8230; \u8d4b\u503c\u521b\u5efa\u7684\u5c5e\u6027&#xff0c;\u5f52\u6bcf\u4e2a\u5b9e\u4f8b\u81ea\u5df1\u6240\u6709&#xff0c;\u4e92\u4e0d\u5e72\u6270<\/li>\n<\/ul>\n<p><span class=\"token keyword\">class<\/span> <span class=\"token class-name\">Employee<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    company <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#034;ByteDance&#034;<\/span>      <span class=\"token comment\"># \u7c7b\u53d8\u91cf&#xff1a;\u6240\u6709 Employee \u5b9e\u4f8b\u5171\u4eab<\/span><\/p>\n<p>    <span class=\"token keyword\">def<\/span> <span class=\"token function\">__init__<\/span><span class=\"token punctuation\">(<\/span>self<span class=\"token punctuation\">,<\/span> name<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        self<span class=\"token punctuation\">.<\/span>name <span class=\"token operator\">&#061;<\/span> name        <span class=\"token comment\"># \u5b9e\u4f8b\u53d8\u91cf&#xff1a;\u6bcf\u4e2a\u5b9e\u4f8b\u72ec\u7acb\u4e00\u4efd<\/span><\/p>\n<hr \/>\n<h3>\u4e8c\u3001\u4e3a\u4ec0\u4e48&#xff1a;\u5c5e\u6027\u67e5\u627e\u987a\u5e8f\u51b3\u5b9a\u4e86\u5171\u4eab\u5173\u7cfb<\/h3>\n<p>instance.attr \u7684\u67e5\u627e\u987a\u5e8f\u5f88\u660e\u786e&#xff1a;\u5148\u67e5\u5b9e\u4f8b\u81ea\u5df1\u7684 __dict__&#xff0c;\u6ca1\u627e\u5230\u518d\u6cbf\u7740\u7c7b\u7684 MRO \u5f80\u4e0a\u67e5\u7c7b\u53d8\u91cf&#xff08;\u4ee5\u53ca\u7236\u7c7b\u53d8\u91cf&#xff09;&#xff0c;\u90fd\u6ca1\u627e\u5230\u624d\u629b AttributeError\u3002\u8fd9\u4e2a\u987a\u5e8f\u89e3\u91ca\u4e86\u7c7b\u53d8\u91cf&#034;\u5171\u4eab&#034;\u7684\u672c\u8d28\u2014\u2014\u5b83\u53ea\u5728\u7c7b\u7684 __dict__ \u91cc\u5b58\u4e86\u4e00\u4efd&#xff0c;\u6240\u6709\u6ca1\u6709\u540c\u540d\u5b9e\u4f8b\u53d8\u91cf\u7684\u5b9e\u4f8b&#xff0c;\u67e5\u5230\u7684\u90fd\u662f\u8fd9\u540c\u4e00\u4efd\u3002<\/p>\n<p>\u7c7b\u53d8\u91cf\u5b58\u5728\u7684\u610f\u4e49\u5f88\u76f4\u63a5&#xff1a;\u7ed9\u6240\u6709\u5b9e\u4f8b\u5171\u4eab\u914d\u7f6e\u3001\u5e38\u91cf\u3001\u8ba1\u6570\u5668\u8fd9\u7c7b&#034;\u4e0d\u9700\u8981\u6bcf\u4e2a\u5b9e\u4f8b\u5404\u5b58\u4e00\u4efd&#034;\u7684\u6570\u636e&#xff0c;\u7701\u5185\u5b58\u4e5f\u8868\u8fbe\u4e86\u8bed\u4e49\u4e0a\u7684&#034;\u8fd9\u662f\u7c7b\u7ea7\u522b\u7684\u4e1c\u897f&#034;\u3002\u95ee\u9898\u51fa\u5728\u53ef\u53d8\u7c7b\u578b\u4e0a&#xff1a;\u5982\u679c\u628a list\/dict \u5f53\u7c7b\u53d8\u91cf\u3001\u53c8\u7528\u539f\u5730\u4fee\u6539\u7684\u65b9\u5f0f\u64cd\u4f5c\u5b83&#xff08;\u6bd4\u5982 self.items.append(x)&#xff09;&#xff0c;\u5e76\u4e0d\u4f1a\u89e6\u53d1&#034;\u5b9e\u4f8b\u906e\u853d&#034;\u7684\u8d4b\u503c\u5206\u652f&#xff0c;\u6240\u6709\u5b9e\u4f8b\u4fee\u6539\u7684\u5176\u5b9e\u662f\u540c\u4e00\u4e2a\u5e95\u5c42\u5bf9\u8c61\u2014\u2014\u8fd9\u6b63\u662f\u5f88\u591a&#034;\u7ebf\u4e0a\u4e8b\u6545&#034;\u7684\u8d77\u70b9\u3002<\/p>\n<p>#mermaid-svg-xlRl2nuGQVoh7ga9{font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-xlRl2nuGQVoh7ga9 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-xlRl2nuGQVoh7ga9 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-xlRl2nuGQVoh7ga9 .error-icon{fill:#552222;}#mermaid-svg-xlRl2nuGQVoh7ga9 .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-xlRl2nuGQVoh7ga9 .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-xlRl2nuGQVoh7ga9 .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-xlRl2nuGQVoh7ga9 .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-xlRl2nuGQVoh7ga9 .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-xlRl2nuGQVoh7ga9 .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-xlRl2nuGQVoh7ga9 .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-xlRl2nuGQVoh7ga9 .marker{fill:#333333;stroke:#333333;}#mermaid-svg-xlRl2nuGQVoh7ga9 .marker.cross{stroke:#333333;}#mermaid-svg-xlRl2nuGQVoh7ga9 svg{font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-xlRl2nuGQVoh7ga9 p{margin:0;}#mermaid-svg-xlRl2nuGQVoh7ga9 .label{font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;color:#333;}#mermaid-svg-xlRl2nuGQVoh7ga9 .cluster-label text{fill:#333;}#mermaid-svg-xlRl2nuGQVoh7ga9 .cluster-label span{color:#333;}#mermaid-svg-xlRl2nuGQVoh7ga9 .cluster-label span p{background-color:transparent;}#mermaid-svg-xlRl2nuGQVoh7ga9 .label text,#mermaid-svg-xlRl2nuGQVoh7ga9 span{fill:#333;color:#333;}#mermaid-svg-xlRl2nuGQVoh7ga9 .node rect,#mermaid-svg-xlRl2nuGQVoh7ga9 .node circle,#mermaid-svg-xlRl2nuGQVoh7ga9 .node ellipse,#mermaid-svg-xlRl2nuGQVoh7ga9 .node polygon,#mermaid-svg-xlRl2nuGQVoh7ga9 .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-xlRl2nuGQVoh7ga9 .rough-node .label text,#mermaid-svg-xlRl2nuGQVoh7ga9 .node .label text,#mermaid-svg-xlRl2nuGQVoh7ga9 .image-shape .label,#mermaid-svg-xlRl2nuGQVoh7ga9 .icon-shape .label{text-anchor:middle;}#mermaid-svg-xlRl2nuGQVoh7ga9 .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-xlRl2nuGQVoh7ga9 .rough-node .label,#mermaid-svg-xlRl2nuGQVoh7ga9 .node .label,#mermaid-svg-xlRl2nuGQVoh7ga9 .image-shape .label,#mermaid-svg-xlRl2nuGQVoh7ga9 .icon-shape .label{text-align:center;}#mermaid-svg-xlRl2nuGQVoh7ga9 .node.clickable{cursor:pointer;}#mermaid-svg-xlRl2nuGQVoh7ga9 .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-xlRl2nuGQVoh7ga9 .arrowheadPath{fill:#333333;}#mermaid-svg-xlRl2nuGQVoh7ga9 .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-xlRl2nuGQVoh7ga9 .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-xlRl2nuGQVoh7ga9 .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-xlRl2nuGQVoh7ga9 .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-xlRl2nuGQVoh7ga9 .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-xlRl2nuGQVoh7ga9 .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-xlRl2nuGQVoh7ga9 .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-xlRl2nuGQVoh7ga9 .cluster text{fill:#333;}#mermaid-svg-xlRl2nuGQVoh7ga9 .cluster span{color:#333;}#mermaid-svg-xlRl2nuGQVoh7ga9 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-xlRl2nuGQVoh7ga9 .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-xlRl2nuGQVoh7ga9 rect.text{fill:none;stroke-width:0;}#mermaid-svg-xlRl2nuGQVoh7ga9 .icon-shape,#mermaid-svg-xlRl2nuGQVoh7ga9 .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-xlRl2nuGQVoh7ga9 .icon-shape p,#mermaid-svg-xlRl2nuGQVoh7ga9 .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-xlRl2nuGQVoh7ga9 .icon-shape .label rect,#mermaid-svg-xlRl2nuGQVoh7ga9 .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-xlRl2nuGQVoh7ga9 .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-xlRl2nuGQVoh7ga9 .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-xlRl2nuGQVoh7ga9 :root{&#8211;mermaid-font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;}<span class=\"edgeLabel\"><\/span><span class=\"edgeLabel\"><\/p>\n<p>\u6709<\/p>\n<p><\/span><span class=\"edgeLabel\"><\/p>\n<p>\u6ca1\u6709<\/p>\n<p><\/span><span class=\"edgeLabel\"><\/span><span class=\"edgeLabel\"><\/span><span class=\"nodeLabel\"><\/p>\n<p>\u8bbf\u95eeinstance.attr<\/p>\n<p><\/span><span class=\"nodeLabel\"><\/p>\n<p>\u5b9e\u4f8b\u5b57\u5178\u91cc\u6709\u8be5\u5c5e\u6027\u5417<\/p>\n<p><\/span><span class=\"nodeLabel\"><\/p>\n<p>\u8fd4\u56de\u5b9e\u4f8b\u53d8\u91cf<\/p>\n<p><\/span><span class=\"nodeLabel\"><\/p>\n<p>\u6cbf\u7740MRO\u67e5\u627e\u7c7b\u5b57\u5178<\/p>\n<p><\/span><span class=\"nodeLabel\"><\/p>\n<p>\u627e\u5230\u7c7b\u53d8\u91cf\u5c31\u8fd4\u56de<\/p>\n<p><\/span><span class=\"nodeLabel\"><\/p>\n<p>\u90fd\u6ca1\u627e\u5230\u5c31\u62a5AttributeError<\/p>\n<p><\/span><\/p>\n<hr \/>\n<h3>\u4e09\u3001\u600e\u4e48\u7528<\/h3>\n<h4>1. \u5171\u4eab\u4e0e\u906e\u853d&#xff1a;\u4fee\u6539\u7c7b\u53d8\u91cf vs \u4fee\u6539\u5b9e\u4f8b\u53d8\u91cf<\/h4>\n<p>e1 <span class=\"token operator\">&#061;<\/span> Employee<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;Alice&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\ne2 <span class=\"token operator\">&#061;<\/span> Employee<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;Bob&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span>e1<span class=\"token punctuation\">.<\/span>company<span class=\"token punctuation\">,<\/span> e2<span class=\"token punctuation\">.<\/span>company<span class=\"token punctuation\">)<\/span>   <span class=\"token comment\"># ByteDance ByteDance<\/span><\/p>\n<p>Employee<span class=\"token punctuation\">.<\/span>company <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#034;TikTok&#034;<\/span>       <span class=\"token comment\"># \u4fee\u6539\u7c7b\u53d8\u91cf\u672c\u8eab<\/span><br \/>\n<span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span>e1<span class=\"token punctuation\">.<\/span>company<span class=\"token punctuation\">,<\/span> e2<span class=\"token punctuation\">.<\/span>company<span class=\"token punctuation\">)<\/span>   <span class=\"token comment\"># TikTok TikTok \u2014\u2014 \u4e24\u4e2a\u5b9e\u4f8b\u90fd\u53d8\u4e86<\/span><\/p>\n<p>e1<span class=\"token punctuation\">.<\/span>company <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#034;Alice&#039;s own&#034;<\/span>        <span class=\"token comment\"># \u6ce8\u610f&#xff1a;\u8fd9\u4e0d\u662f&#034;\u4fee\u6539&#034;\u7c7b\u53d8\u91cf&#xff0c;\u662f\u7ed9 e1.__dict__ \u65b0\u589e\u4e00\u4e2a\u540c\u540d\u5b9e\u4f8b\u53d8\u91cf<\/span><br \/>\n<span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span>e1<span class=\"token punctuation\">.<\/span>__dict__<span class=\"token punctuation\">)<\/span>                <span class=\"token comment\"># {&#039;name&#039;: &#039;Alice&#039;, &#039;company&#039;: &#034;Alice&#039;s own&#034;}<\/span><br \/>\n<span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span>e1<span class=\"token punctuation\">.<\/span>company<span class=\"token punctuation\">,<\/span> e2<span class=\"token punctuation\">.<\/span>company<span class=\"token punctuation\">)<\/span>   <span class=\"token comment\"># Alice&#039;s own TikTok \u2014\u2014 e1 \u6709\u4e86\u81ea\u5df1\u7684 company&#xff0c;e2 \u4ecd\u8bfb\u7c7b\u53d8\u91cf<\/span><br \/>\n<span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span>Employee<span class=\"token punctuation\">.<\/span>company<span class=\"token punctuation\">)<\/span>           <span class=\"token comment\"># TikTok \u2014\u2014 \u7c7b\u53d8\u91cf\u672c\u8eab\u6ca1\u88ab e1 \u90a3\u884c\u6539\u52a8<\/span><\/p>\n<p>instance.attr &#061; value \u6c38\u8fdc\u53ea\u4f1a\u64cd\u4f5c\u5b9e\u4f8b\u81ea\u5df1\u7684 __dict__&#xff0c;\u7edd\u4e0d\u4f1a\u4fee\u6539\u7c7b\u53d8\u91cf\u2014\u2014\u8fd9\u4e5f\u662f\u4e3a\u4ec0\u4e48\u5b83\u53eb&#034;\u906e\u853d&#034;\u800c\u4e0d\u662f&#034;\u4fee\u6539&#034;\u3002\u771f\u6b63\u60f3\u6539\u7c7b\u53d8\u91cf&#xff0c;\u5fc5\u987b\u901a\u8fc7\u7c7b\u540d ClassName.attr &#061; value\u3002<\/p>\n<h4>2. \u4e8b\u6545\u73b0\u573a&#xff1a;\u53ef\u53d8\u7c7b\u53d8\u91cf\u88ab\u5f53\u6210&#034;\u6bcf\u4e2a\u5b9e\u4f8b\u72ec\u7acb&#034;\u6765\u7528<\/h4>\n<p><span class=\"token keyword\">class<\/span> <span class=\"token class-name\">ShoppingCart<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    items <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span>              <span class=\"token comment\"># \u672c\u610f&#xff1a;\u7ed9\u6bcf\u4e2a\u8d2d\u7269\u8f66\u4e00\u4e2a\u7a7a\u5217\u8868&#xff1b;\u5b9e\u9645&#xff1a;\u6240\u6709\u8d2d\u7269\u8f66\u5171\u4eab\u540c\u4e00\u4e2a list \u5bf9\u8c61<\/span><\/p>\n<p>    <span class=\"token keyword\">def<\/span> <span class=\"token function\">add<\/span><span class=\"token punctuation\">(<\/span>self<span class=\"token punctuation\">,<\/span> item<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        self<span class=\"token punctuation\">.<\/span>items<span class=\"token punctuation\">.<\/span>append<span class=\"token punctuation\">(<\/span>item<span class=\"token punctuation\">)<\/span>   <span class=\"token comment\"># \u539f\u5730\u4fee\u6539&#xff0c;\u4e0d\u662f\u8d4b\u503c&#xff0c;\u4e0d\u4f1a\u521b\u5efa\u5b9e\u4f8b\u53d8\u91cf<\/span><\/p>\n<p>cart1 <span class=\"token operator\">&#061;<\/span> ShoppingCart<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\ncart2 <span class=\"token operator\">&#061;<\/span> ShoppingCart<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\ncart1<span class=\"token punctuation\">.<\/span>add<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;\u82f9\u679c&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span>cart2<span class=\"token punctuation\">.<\/span>items<span class=\"token punctuation\">)<\/span>   <span class=\"token comment\"># [&#039;\u82f9\u679c&#039;] \u2014\u2014 cart2 \u4ec0\u4e48\u90fd\u6ca1\u505a&#xff0c;\u8d2d\u7269\u8f66\u91cc\u5374\u591a\u4e86\u4e2a\u82f9\u679c<\/span><\/p>\n<p>\u5173\u952e\u5728 self.items.append(item) \u8fd9\u4e00\u884c&#xff1a;\u5b83\u662f\u5bf9 items \u6307\u5411\u7684\u540c\u4e00\u4e2a list \u5bf9\u8c61\u539f\u5730\u4fee\u6539&#xff0c;self.items \u672c\u8eab\u6ca1\u6709\u53d1\u751f\u8d4b\u503c\u52a8\u4f5c&#xff0c;\u6240\u4ee5\u67e5\u627e\u987a\u5e8f\u91cc&#034;\u5b9e\u4f8b\u906e\u853d&#034;\u90a3\u4e00\u652f\u6839\u672c\u6ca1\u88ab\u89e6\u53d1\u2014\u2014cart1\u3001cart2 \u4ece\u5934\u5230\u5c3e\u90fd\u5728\u8bfb\u5199\u7c7b\u53d8\u91cf ShoppingCart.items \u8fd9\u540c\u4e00\u4e2a\u5bf9\u8c61\u3002\u8fd9\u8ddf Day01 \u8bb2\u7684&#034;\u53ef\u53d8\u9ed8\u8ba4\u53c2\u6570\u88ab\u591a\u6b21\u8c03\u7528\u5171\u4eab&#034;\u662f\u4e00\u6a21\u4e00\u6837\u7684\u5751&#xff0c;\u53ea\u662f\u5171\u4eab\u7684\u8f7d\u4f53\u4ece\u51fd\u6570\u53c2\u6570\u6362\u6210\u4e86\u7c7b\u5c5e\u6027\u3002<\/p>\n<p>\u4fee\u590d\u65b9\u5f0f\u4e5f\u4e00\u6837&#xff1a;\u5728 __init__ \u91cc\u663e\u5f0f\u8d4b\u503c&#xff0c;\u628a\u5b83\u53d8\u6210\u771f\u6b63\u7684\u5b9e\u4f8b\u53d8\u91cf&#xff1a;<\/p>\n<p><span class=\"token keyword\">class<\/span> <span class=\"token class-name\">ShoppingCart<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token keyword\">def<\/span> <span class=\"token function\">__init__<\/span><span class=\"token punctuation\">(<\/span>self<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        self<span class=\"token punctuation\">.<\/span>items <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span>          <span class=\"token comment\"># \u663e\u5f0f\u5728 __init__ \u91cc\u521b\u5efa&#xff0c;\u6bcf\u4e2a\u5b9e\u4f8b\u90fd\u4f1a\u6267\u884c\u4e00\u6b21&#xff0c;\u5404\u81ea\u72ec\u7acb<\/span><\/p>\n<p>    <span class=\"token keyword\">def<\/span> <span class=\"token function\">add<\/span><span class=\"token punctuation\">(<\/span>self<span class=\"token punctuation\">,<\/span> item<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        self<span class=\"token punctuation\">.<\/span>items<span class=\"token punctuation\">.<\/span>append<span class=\"token punctuation\">(<\/span>item<span class=\"token punctuation\">)<\/span><\/p>\n<h4>3. \u8ba1\u6570\u5668\u573a\u666f&#xff1a;self.count &#043;&#061; 1 \u4e3a\u4ec0\u4e48\u4f1a\u5e9f\u6389\u8ba1\u6570<\/h4>\n<p>\u7c7b\u53d8\u91cf\u505a\u5b9e\u4f8b\u8ba1\u6570\u5668\u662f\u5e38\u89c1\u7684\u5408\u7406\u7528\u6cd5&#xff0c;\u4f46\u4e00\u4e2a\u5f88\u5bb9\u6613\u72af\u7684\u9519\u8bef\u662f\u7528 self \u53bb\u7d2f\u52a0&#xff1a;<\/p>\n<p><span class=\"token keyword\">class<\/span> <span class=\"token class-name\">Employee<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    count <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0<\/span><\/p>\n<p>    <span class=\"token keyword\">def<\/span> <span class=\"token function\">__init__<\/span><span class=\"token punctuation\">(<\/span>self<span class=\"token punctuation\">,<\/span> name<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        self<span class=\"token punctuation\">.<\/span>name <span class=\"token operator\">&#061;<\/span> name<br \/>\n        self<span class=\"token punctuation\">.<\/span>count <span class=\"token operator\">&#043;&#061;<\/span> <span class=\"token number\">1<\/span>   <span class=\"token comment\"># \u9519\u8bef\u5199\u6cd5<\/span><\/p>\n<p>e1 <span class=\"token operator\">&#061;<\/span> Employee<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;Alice&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\ne2 <span class=\"token operator\">&#061;<\/span> Employee<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;Bob&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span>Employee<span class=\"token punctuation\">.<\/span>count<span class=\"token punctuation\">)<\/span>   <span class=\"token comment\"># 0 \u2014\u2014 \u8ba1\u6570\u5668\u5b8c\u5168\u6ca1\u5de5\u4f5c<\/span><br \/>\n<span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span>e1<span class=\"token punctuation\">.<\/span>count<span class=\"token punctuation\">,<\/span> e2<span class=\"token punctuation\">.<\/span>count<span class=\"token punctuation\">)<\/span>   <span class=\"token comment\"># 1 1 \u2014\u2014 \u4f46\u4e24\u4e2a\u5b9e\u4f8b\u4e0a\u5404\u81ea&#034;\u770b\u8d77\u6765&#034;\u8ba1\u6570\u6b63\u786e<\/span><\/p>\n<p>self.count &#043;&#061; 1 \u7b49\u4ef7\u4e8e self.count &#061; self.count &#043; 1&#xff1a;\u53f3\u8fb9\u8bfb\u53d6\u65f6&#xff0c;\u5b9e\u4f8b\u81ea\u5df1\u6ca1\u6709 count&#xff0c;\u8d70\u67e5\u627e\u987a\u5e8f\u627e\u5230\u7c7b\u53d8\u91cf&#xff08;\u5f53\u65f6\u662f 0&#xff09;&#xff0c;\u7b97\u51fa 1&#xff1b;\u4f46\u5de6\u8fb9\u8d4b\u503c\u4f1a\u5728\u5f53\u524d\u5b9e\u4f8b\u7684 __dict__ \u91cc\u65b0\u5efa\u4e00\u4e2a count &#061; 1 \u7684\u5b9e\u4f8b\u53d8\u91cf\u3002\u4ece\u8fd9\u4e00\u884c\u5f00\u59cb&#xff0c;\u8fd9\u4e2a\u5b9e\u4f8b\u7684 count \u5c31\u548c\u7c7b\u53d8\u91cf\u5f7b\u5e95\u8131\u94a9\u4e86&#xff0c;\u540e\u7eed\u5bf9\u5b83\u7684\u4efb\u4f55 &#043;&#061; 1 \u90fd\u53ea\u4f1a\u66f4\u65b0\u5b83\u81ea\u5df1\u90a3\u4efd&#xff0c;\u7c7b\u53d8\u91cf Employee.count \u6c38\u8fdc\u505c\u5728 0\u3002\u6b63\u786e\u5199\u6cd5\u5fc5\u987b\u663e\u5f0f\u7528\u7c7b\u540d&#xff1a;<\/p>\n<p><span class=\"token keyword\">class<\/span> <span class=\"token class-name\">Employee<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    count <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0<\/span><\/p>\n<p>    <span class=\"token keyword\">def<\/span> <span class=\"token function\">__init__<\/span><span class=\"token punctuation\">(<\/span>self<span class=\"token punctuation\">,<\/span> name<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        self<span class=\"token punctuation\">.<\/span>name <span class=\"token operator\">&#061;<\/span> name<br \/>\n        Employee<span class=\"token punctuation\">.<\/span>count <span class=\"token operator\">&#043;&#061;<\/span> <span class=\"token number\">1<\/span>   <span class=\"token comment\"># \u663e\u5f0f\u64cd\u4f5c\u7c7b\u53d8\u91cf&#xff0c;\u4e0d\u7ed9\u5b9e\u4f8b\u906e\u853d\u7684\u673a\u4f1a<\/span><\/p>\n<p><span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span>Employee<span class=\"token punctuation\">.<\/span>count<span class=\"token punctuation\">)<\/span>   <span class=\"token comment\"># 2<\/span><\/p>\n<h4>4. \u600e\u4e48\u5feb\u901f\u5224\u65ad\u4e00\u4e2a\u5c5e\u6027\u5230\u5e95\u662f\u7c7b\u53d8\u91cf\u8fd8\u662f\u5b9e\u4f8b\u53d8\u91cf<\/h4>\n<p><span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span>e1<span class=\"token punctuation\">.<\/span>__dict__<span class=\"token punctuation\">)<\/span>          <span class=\"token comment\"># \u53ea\u5305\u542b\u5b9e\u4f8b\u53d8\u91cf<\/span><br \/>\n<span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span><span class=\"token builtin\">type<\/span><span class=\"token punctuation\">(<\/span>e1<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span>__dict__<span class=\"token punctuation\">)<\/span>   <span class=\"token comment\"># \u5305\u542b\u7c7b\u53d8\u91cf\u3001\u65b9\u6cd5\u7b49\u7c7b\u7ea7\u522b\u7684\u4e1c\u897f<\/span><\/p>\n<hr \/>\n<h3>\u56db\u3001\u9762\u8bd5\u8ffd\u95ee<\/h3>\n<p>Q1&#xff1a;instance.attr \u7684\u67e5\u627e\u987a\u5e8f\u662f\u4ec0\u4e48&#xff1f;<\/p>\n<p>\u5148\u67e5\u5b9e\u4f8b\u81ea\u5df1\u7684 __dict__&#xff0c;\u6ca1\u627e\u5230\u518d\u6cbf\u7740\u7c7b\u7684 MRO \u5f80\u4e0a\u67e5\u7c7b\u53d8\u91cf\u53ca\u7236\u7c7b\u53d8\u91cf&#xff0c;\u90fd\u6ca1\u627e\u5230\u624d\u629b AttributeError\u3002\u800c instance.attr &#061; value \u8fd9\u79cd\u8d4b\u503c\u64cd\u4f5c\u6c38\u8fdc\u53ea\u4f5c\u7528\u4e8e\u5b9e\u4f8b\u7684 __dict__&#xff0c;\u4e0d\u4f1a\u4fee\u6539\u7c7b\u53d8\u91cf&#xff0c;\u54ea\u6015\u540c\u540d\u7684\u7c7b\u53d8\u91cf\u5df2\u7ecf\u5b58\u5728\u3002<\/p>\n<p>Q2&#xff1a;\u4e3a\u4ec0\u4e48\u7528\u53ef\u53d8\u7c7b\u578b\u505a\u7c7b\u53d8\u91cf\u3001\u53c8\u901a\u8fc7\u539f\u5730\u4fee\u6539\u64cd\u4f5c\u5b83&#xff0c;\u7279\u522b\u5bb9\u6613\u51fa\u95ee\u9898&#xff1f;<\/p>\n<p>\u56e0\u4e3a\u539f\u5730\u4fee\u6539&#xff08;list.append\u3001dict[k]&#061;v \u7b49&#xff09;\u4e0d\u6d89\u53ca\u5bf9 self.attr \u7684\u8d4b\u503c\u52a8\u4f5c&#xff0c;\u4e0d\u4f1a\u89e6\u53d1\u67e5\u627e\u987a\u5e8f\u91cc&#034;\u7ed9\u5b9e\u4f8b\u521b\u5efa\u540c\u540d\u6761\u76ee&#034;\u7684\u90a3\u4e00\u652f&#xff0c;\u6240\u6709\u5b9e\u4f8b\u64cd\u4f5c\u7684\u59cb\u7ec8\u662f\u7c7b\u53d8\u91cf\u6307\u5411\u7684\u540c\u4e00\u4e2a\u5e95\u5c42\u5bf9\u8c61\u3002\u8fd9\u548c Day01 \u8bb2\u7684\u53ef\u53d8\u9ed8\u8ba4\u53c2\u6570\u9677\u9631\u662f\u540c\u4e00\u7c7b\u95ee\u9898\u7684\u4e24\u79cd\u53d8\u4f53&#xff1a;\u672c\u8be5\u6bcf\u4e2a\u4f7f\u7528\u8005\u72ec\u7acb\u4e00\u4efd\u7684\u53ef\u53d8\u5bf9\u8c61&#xff0c;\u88ab\u65e0\u610f\u4e2d\u5171\u4eab\u4e86\u3002<\/p>\n<p>Q3&#xff1a;\u8ba1\u6570\u5668\u573a\u666f\u4e0b self.count &#043;&#061; 1 \u9519\u5728\u54ea&#xff0c;\u6b63\u786e\u5199\u6cd5\u662f\u4ec0\u4e48&#xff1f;<\/p>\n<p>&#043;&#061; \u5206\u8bfb\u548c\u5199\u4e24\u6b65&#xff1a;\u8bfb\u7684\u65f6\u5019\u8d70\u67e5\u627e\u987a\u5e8f\u62ff\u5230\u7c7b\u53d8\u91cf\u7684\u503c&#xff0c;\u4f46\u5199\u7684\u65f6\u5019\u4f1a\u5728\u5f53\u524d\u5b9e\u4f8b\u7684 __dict__ \u91cc\u65b0\u5efa\u4e00\u4e2a\u540c\u540d\u5b9e\u4f8b\u53d8\u91cf&#xff0c;\u5bfc\u81f4\u8fd9\u4e2a\u5b9e\u4f8b\u7684 count \u4ece\u6b64\u548c\u7c7b\u53d8\u91cf\u8131\u94a9&#xff0c;\u540e\u7eed\u64cd\u4f5c\u90fd\u53ea\u66f4\u65b0\u5b83\u81ea\u5df1\u90a3\u4efd&#xff0c;\u7c7b\u53d8\u91cf\u672c\u8eab\u6c38\u8fdc\u4e0d\u53d8\u3002\u6b63\u786e\u5199\u6cd5\u662f\u663e\u5f0f\u7528\u7c7b\u540d ClassName.count &#043;&#061; 1&#xff0c;\u7ed5\u5f00\u5b9e\u4f8b\u906e\u853d\u3002<\/p>\n<p>Q4&#xff1a;\u600e\u4e48\u5728\u4ee3\u7801\u91cc\u5feb\u901f\u786e\u8ba4\u4e00\u4e2a\u5c5e\u6027\u5230\u5e95\u662f\u7c7b\u53d8\u91cf\u8fd8\u662f\u5b9e\u4f8b\u53d8\u91cf&#xff1f;<\/p>\n<p>\u770b instance.__dict__&#xff08;\u53ea\u542b\u5b9e\u4f8b\u53d8\u91cf&#xff09;\u548c type(instance).__dict__&#xff08;\u542b\u7c7b\u53d8\u91cf\u3001\u65b9\u6cd5\u7b49\u7c7b\u7ea7\u522b\u6210\u5458&#xff09;&#xff0c;\u4e8c\u8005\u90fd\u6ca1\u6709\u624d\u4f1a\u7ee7\u7eed\u5f80\u7236\u7c7b\u7684 __dict__ \u67e5&#xff08;\u5bf9\u5e94 MRO \u94fe&#xff09;\u3002<\/p>\n<hr \/>\n<h3>\u4e0b\u4e00\u7bc7\u9884\u544a<\/h3>\n<p>Day12 \u8bb2 __new__ vs __init__\u2014\u2014\u5bf9\u8c61\u521b\u5efa\u5176\u5b9e\u5206\u4e24\u4e2a\u9636\u6bb5&#xff0c;__new__ \u8d1f\u8d23\u771f\u6b63&#034;\u9020\u51fa&#034;\u8fd9\u4e2a\u5bf9\u8c61&#xff0c;__init__ \u53ea\u8d1f\u8d23\u521d\u59cb\u5316&#xff0c;\u8fd9\u4e2a\u533a\u5206\u5728\u5355\u4f8b\u6a21\u5f0f\u3001\u4e0d\u53ef\u53d8\u5bf9\u8c61\u573a\u666f\u91cc\u4f1a\u53d8\u5f97\u5f88\u5173\u952e\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u300cPython \u8fdb\u9636\u4e4b\u8def\u300d\u7cfb\u5217 Day11\u5199\u5728\u524d\u9762<br \/>\n\u6a21\u5757\u4e8c\u51fd\u6570\u5f0f\u7f16\u7a0b\u7cfb\u5217\u5199\u5b8c&#xff0c;\u4eca\u5929\u5f00\u59cb\u6a21\u5757\u4e09\u9762\u5411\u5bf9\u8c61\u8fdb\u9636\u3002\u7b2c\u4e00\u7bc7\u8bb2\u4e00\u4e2a\u770b\u8d77\u6765\u5f88\u57fa\u7840\u3001\u4f46\u51e0\u4e4e\u4eba\u4eba\u90fd\u8e29\u8fc7\u7684\u5751&#xff1a;\u7c7b\u53d8\u91cf\u548c\u5b9e\u4f8b\u53d8\u91cf\u5206\u4e0d\u6e05\u695a&#xff0c;\u5c24\u5176\u662f\u7528\u53ef\u53d8\u7c7b\u578b&#xff08;list\/dict&#xff09;\u5f53\u7c7b\u53d8\u91cf\u65f6&#xff0c;\u672c\u610f\u662f\\&#8221;\u6bcf\u4e2a\u5b9e\u4f8b\u4e00\u4efd\u72ec\u7acb\u6570\u636e\\&#8221;&#xff0c;\u7ed3\u679c\u5374\u662f\u6240\u6709\u5b9e\u4f8b\u5171\u4eab\u540c\u4e00\u4efd\u2014\u2014\u8fd9\u8ddf Day01 \u8bb2\u7684\u53ef\u53d8\u9ed8\u8ba4\u53c2\u6570\u9677\u9631\u5176\u5b9e\u662f\u540c\u4e00\u7c7b\u95ee\u9898\u7684\u4e24\u79cd\u53d8\u4f53\u3002\u4e00\u3001\u662f\u4ec0\u4e48&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,190],"topic":[],"class_list":["post-95544","post","type-post","status-publish","format-standard","hentry","category-server","tag-python","tag-190"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u7c7b\u53d8\u91cf\u4e0e\u5b9e\u4f8b\u53d8\u91cf\uff1a\u4e00\u4e2a\u5171\u4eab\u5217\u8868\u5f15\u53d1\u7684\u7ebf\u4e0a\u4e8b\u6545 - \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\/95544.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u7c7b\u53d8\u91cf\u4e0e\u5b9e\u4f8b\u53d8\u91cf\uff1a\u4e00\u4e2a\u5171\u4eab\u5217\u8868\u5f15\u53d1\u7684\u7ebf\u4e0a\u4e8b\u6545 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u300cPython \u8fdb\u9636\u4e4b\u8def\u300d\u7cfb\u5217 Day11\u5199\u5728\u524d\u9762 \u6a21\u5757\u4e8c\u51fd\u6570\u5f0f\u7f16\u7a0b\u7cfb\u5217\u5199\u5b8c&#xff0c;\u4eca\u5929\u5f00\u59cb\u6a21\u5757\u4e09\u9762\u5411\u5bf9\u8c61\u8fdb\u9636\u3002\u7b2c\u4e00\u7bc7\u8bb2\u4e00\u4e2a\u770b\u8d77\u6765\u5f88\u57fa\u7840\u3001\u4f46\u51e0\u4e4e\u4eba\u4eba\u90fd\u8e29\u8fc7\u7684\u5751&#xff1a;\u7c7b\u53d8\u91cf\u548c\u5b9e\u4f8b\u53d8\u91cf\u5206\u4e0d\u6e05\u695a&#xff0c;\u5c24\u5176\u662f\u7528\u53ef\u53d8\u7c7b\u578b&#xff08;list\/dict&#xff09;\u5f53\u7c7b\u53d8\u91cf\u65f6&#xff0c;\u672c\u610f\u662f&quot;\u6bcf\u4e2a\u5b9e\u4f8b\u4e00\u4efd\u72ec\u7acb\u6570\u636e&quot;&#xff0c;\u7ed3\u679c\u5374\u662f\u6240\u6709\u5b9e\u4f8b\u5171\u4eab\u540c\u4e00\u4efd\u2014\u2014\u8fd9\u8ddf Day01 \u8bb2\u7684\u53ef\u53d8\u9ed8\u8ba4\u53c2\u6570\u9677\u9631\u5176\u5b9e\u662f\u540c\u4e00\u7c7b\u95ee\u9898\u7684\u4e24\u79cd\u53d8\u4f53\u3002\u4e00\u3001\u662f\u4ec0\u4e48&amp;#xff1a\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/95544.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-08-26T06:48:29+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=\"5 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/95544.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/95544.html\",\"name\":\"\u7c7b\u53d8\u91cf\u4e0e\u5b9e\u4f8b\u53d8\u91cf\uff1a\u4e00\u4e2a\u5171\u4eab\u5217\u8868\u5f15\u53d1\u7684\u7ebf\u4e0a\u4e8b\u6545 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-08-26T06:48:29+00:00\",\"dateModified\":\"2026-08-26T06:48:29+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/95544.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/95544.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/95544.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u7c7b\u53d8\u91cf\u4e0e\u5b9e\u4f8b\u53d8\u91cf\uff1a\u4e00\u4e2a\u5171\u4eab\u5217\u8868\u5f15\u53d1\u7684\u7ebf\u4e0a\u4e8b\u6545\"}]},{\"@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":"\u7c7b\u53d8\u91cf\u4e0e\u5b9e\u4f8b\u53d8\u91cf\uff1a\u4e00\u4e2a\u5171\u4eab\u5217\u8868\u5f15\u53d1\u7684\u7ebf\u4e0a\u4e8b\u6545 - \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\/95544.html","og_locale":"zh_CN","og_type":"article","og_title":"\u7c7b\u53d8\u91cf\u4e0e\u5b9e\u4f8b\u53d8\u91cf\uff1a\u4e00\u4e2a\u5171\u4eab\u5217\u8868\u5f15\u53d1\u7684\u7ebf\u4e0a\u4e8b\u6545 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u300cPython \u8fdb\u9636\u4e4b\u8def\u300d\u7cfb\u5217 Day11\u5199\u5728\u524d\u9762 \u6a21\u5757\u4e8c\u51fd\u6570\u5f0f\u7f16\u7a0b\u7cfb\u5217\u5199\u5b8c&#xff0c;\u4eca\u5929\u5f00\u59cb\u6a21\u5757\u4e09\u9762\u5411\u5bf9\u8c61\u8fdb\u9636\u3002\u7b2c\u4e00\u7bc7\u8bb2\u4e00\u4e2a\u770b\u8d77\u6765\u5f88\u57fa\u7840\u3001\u4f46\u51e0\u4e4e\u4eba\u4eba\u90fd\u8e29\u8fc7\u7684\u5751&#xff1a;\u7c7b\u53d8\u91cf\u548c\u5b9e\u4f8b\u53d8\u91cf\u5206\u4e0d\u6e05\u695a&#xff0c;\u5c24\u5176\u662f\u7528\u53ef\u53d8\u7c7b\u578b&#xff08;list\/dict&#xff09;\u5f53\u7c7b\u53d8\u91cf\u65f6&#xff0c;\u672c\u610f\u662f\"\u6bcf\u4e2a\u5b9e\u4f8b\u4e00\u4efd\u72ec\u7acb\u6570\u636e\"&#xff0c;\u7ed3\u679c\u5374\u662f\u6240\u6709\u5b9e\u4f8b\u5171\u4eab\u540c\u4e00\u4efd\u2014\u2014\u8fd9\u8ddf Day01 \u8bb2\u7684\u53ef\u53d8\u9ed8\u8ba4\u53c2\u6570\u9677\u9631\u5176\u5b9e\u662f\u540c\u4e00\u7c7b\u95ee\u9898\u7684\u4e24\u79cd\u53d8\u4f53\u3002\u4e00\u3001\u662f\u4ec0\u4e48&amp;#xff1a","og_url":"https:\/\/www.wsisp.com\/helps\/95544.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-08-26T06:48:29+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"5 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/95544.html","url":"https:\/\/www.wsisp.com\/helps\/95544.html","name":"\u7c7b\u53d8\u91cf\u4e0e\u5b9e\u4f8b\u53d8\u91cf\uff1a\u4e00\u4e2a\u5171\u4eab\u5217\u8868\u5f15\u53d1\u7684\u7ebf\u4e0a\u4e8b\u6545 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-08-26T06:48:29+00:00","dateModified":"2026-08-26T06:48:29+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/95544.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/95544.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/95544.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u7c7b\u53d8\u91cf\u4e0e\u5b9e\u4f8b\u53d8\u91cf\uff1a\u4e00\u4e2a\u5171\u4eab\u5217\u8868\u5f15\u53d1\u7684\u7ebf\u4e0a\u4e8b\u6545"}]},{"@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\/95544","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=95544"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/95544\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=95544"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=95544"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=95544"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=95544"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}