{"id":468,"date":"2019-08-30T14:42:14","date_gmt":"2019-08-30T06:42:14","guid":{"rendered":"http:\/\/www.yumefx.com\/?p=468"},"modified":"2021-03-04T17:35:20","modified_gmt":"2021-03-04T09:35:20","slug":"python%e7%9a%84%e5%8f%98%e9%87%8f","status":"publish","type":"post","link":"https:\/\/www.yumefx.com\/?p=468","title":{"rendered":"python\u7684\u53d8\u91cf"},"content":{"rendered":"\n<p>\u5728\u591a\u5e74\u5f00\u53d1\u548c\u6559\u5b66 Python \u7684\u8fc7\u7a0b\u4e2d\uff0c\u6709\u4e00\u4e2a bug\uff0c\u51fa\u73b0\u7684\u9891\u7387\u975e\u5e38\u9ad8\uff0c\u7ecf\u5e38\u6709\u4eba\u4f1a\u8e29\u5751\uff1a<\/p>\n\n\n\n<pre><span>person = {'name': '', 'id': 0}<\/span>\n<span>team = []<\/span>\n<span><\/span>\n<span>for i in range(3):<\/span>\n<span>    x = person<\/span>\n<span>    x['id'] = i<\/span>\n<span>    team.append(x)<\/span>\n<span><\/span>\n<span>team[0]['name'] = 'Jack'<\/span>\n<span>team[1]['name'] = 'Pony'<\/span>\n<span>team[2]['name'] = 'Crossin'<\/span>\n<span><\/span>\n<span>print(team[1]) <\/span>\n<\/pre>\n\n\n\n<p>\u5982\u679c\u89c9\u5f97\u8fd9\u4e2a\u8f93\u51fa\u7ed3\u679c\u662f {&#8216;name&#8217;: &#8216;Pony&#8217;, &#8216;id&#8217;: 1} \uff0c\u90a3\u4e48\u5c31\u6389\u8fdb\u8fd9\u4e2a\u5751\u91cc\u4e86\u3002<\/p>\n<p>\u5982\u679c\u771f\u7684\u8fd0\u884c\u4e00\u4e0b\u5c31\u4f1a\u53d1\u73b0\uff0cteam\u91cc\u9762\u4e09\u4e2a\u90fd\u662f {\u2018name\u2019: \u2018Crossin\u2019, \u2018id\u2019: 2} \uff0c \u800c\u4e14\uff0c\u5982\u679c\u4e4b\u540e\u518d\u66f4\u6539\u4efb\u4f55\u4e00\u4e2a\u7684 name \u6216 id \u5c5e\u6027\uff0c\u53e6\u5916\u4e24\u4e2a\u4e5f\u4f1a\u8ddf\u7740\u53d8\u3002<\/p>\n<p>\u90a3\u4e48\u4e3a\u4ec0\u4e48\u5462\uff1f<\/p>\n<p class=\"has-text-color has-vivid-red-color\"><strong>\u5728 Python \u4e2d\uff0c\u8981\u628a\u53d8\u91cf\u60f3\u8c61\u6210\u4e00\u4e2a\u6807\u7b7e\uff0c\u800c\u4e0d\u662f\u4e00\u4e2a\u5bb9\u5668\uff01<\/strong><\/p>\n<p>\u4ec0\u4e48\u610f\u601d\uff1f\u5728\u67d0\u4e9b\u8bed\u8a00\u4e2d\uff0c\u53d8\u91cf\u786e\u5b9e\u50cf\u4e00\u4e2a\u201c\u5bb9\u5668\u201d\uff0c\u4f60\u5b9a\u4e49\u4e86\u67d0\u79cd\u7c7b\u578b\u7684\u53d8\u91cf\uff0c\u5c31\u7ed9\u4f60\u5206\u914d\u597d\u8fd9\u4e2a\u5bb9\u5668\uff0c\u4e4b\u540e\u4f60\u7ed9\u53d8\u91cf\u8d4b\u503c\uff0c\u5c31\u50cf\u662f\u5f80\u5bb9\u5668\u91cc\u88c5\u5165\u4e0d\u540c\u7684\u5185\u5bb9\uff0c\u4f46\u5bb9\u5668\u8fd8\u662f\u90a3\u4e2a\u5bb9\u5668\uff0c\u4e0d\u4f1a\u53d8\u3002\u4f60\u521b\u5efa3\u4e2a\u5bb9\u5668\uff0c\u8d4b\u7ed9\u4e00\u6837\u7684\u503c\uff0c\u4ed6\u4eec\u4e5f\u8fd8\u662f3\u4e2a\u72ec\u7acb\u7684\u5bb9\u5668\u3002<\/p>\n<p><strong>\u4f46\u5728 Python \u4e2d\uff0c\u8fd9\u4e2a\u7406\u89e3\u662f\u9519\u8bef\u7684\uff01<\/strong><\/p>\n<p>Python \u4e2d\u7684\u53d8\u91cf\u50cf\u662f\u4e00\u4e2a\u201c\u6807\u7b7e\u201d\uff0c\u4f60\u7ed9\u4e00\u4e2a\u53d8\u91cf\u8d4b\u503c\uff0c\u5c31\u662f\u628a\u8fd9\u4e2a\u6807\u7b7e\u8d34\u5728\u4e00\u4e2a\u5bf9\u8c61\u4e0a\uff1b\u91cd\u65b0\u8d4b\u503c\uff0c\u5c31\u662f\u6495\u4e0b\u6807\u7b7e\u5e16\u5230\u53e6\u4e00\u4e2a\u5bf9\u8c61\u4e0a\u3002<\/p>\n<p><strong>\u7ed93\u4e2a\u53d8\u91cf\u8d4b\u7ed9\u4e00\u6837\u7684\u503c\uff0c\u5c31\u76f8\u5f53\u4e8e\u628a3\u4e2a\u6807\u7b7e\u8d34\u5728\u540c\u4e00\u4e2a\u5bf9\u8c61\u4e0a<\/strong>\u3002<\/p>\n<p>\u7528\u4f8b\u5b50\u6765\u8bf4\u660e\uff1a<\/p>\n\n\n\n<pre><span>a = 1<\/span>\n<span>b = 2<\/span>\n<span>c = 1<\/span>\n<span># \u518d\u6b21\u8d4b\u503c<\/span>\n<span>a = b <\/span>\n<\/pre>\n\n\n\n<p>\u793a\u610f\u56fe\uff1a<\/p>\n<p><img loading=\"lazy\" class=\"size-full wp-image-1073 aligncenter\" src=\"http:\/\/www.yumefx.com\/wp-content\/uploads\/2019\/08\/pythonFuzhi1.jpg\" alt=\"\" width=\"740\" height=\"782\" srcset=\"https:\/\/www.yumefx.com\/wp-content\/uploads\/2019\/08\/pythonFuzhi1.jpg 740w, https:\/\/www.yumefx.com\/wp-content\/uploads\/2019\/08\/pythonFuzhi1-284x300.jpg 284w\" sizes=\"(max-width: 740px) 100vw, 740px\" \/><\/p>\n<p>\u901a\u8fc7\u8f93\u51fa id\uff08\u76f8\u5f53\u4e8e\u5185\u5b58\u5730\u5740\uff09\u4e5f\u53ef\u4ee5\u8bf4\u660e\u8fd9\u70b9\uff1a<\/p>\n<p><img loading=\"lazy\" class=\"size-full wp-image-1074 aligncenter\" src=\"http:\/\/www.yumefx.com\/wp-content\/uploads\/2019\/08\/pythonFuzhi2.jpg\" alt=\"\" width=\"608\" height=\"702\" srcset=\"https:\/\/www.yumefx.com\/wp-content\/uploads\/2019\/08\/pythonFuzhi2.jpg 608w, https:\/\/www.yumefx.com\/wp-content\/uploads\/2019\/08\/pythonFuzhi2-260x300.jpg 260w\" sizes=\"(max-width: 608px) 100vw, 608px\" \/><\/p>\n<p>\u5728\u8d4b\u503c\u4e4b\u540e\uff0c\u5176\u5b9e\u5e76\u4e0d\u662f a \u7684\u503c\u53d1\u751f\u4e86\u53d8\u5316\uff0c\u800c\u662f a \u7684\u5730\u5740\u53d1\u751f\u4e86\u53d8\u5316\u3002<\/p>\n<p>\u7406\u89e3\u4e86\u8fd9\u70b9\u4e4b\u540e\uff0c\u4f60\u5c31\u4f1a\u660e\u767d2\u4ef6\u4e8b\uff1a<\/p>\n<ol>\n<li>\u5f53\u4f60\u7ed9\u4e00\u4e2a\u53d8\u91cf\u91cd\u65b0\u8d4b\u503c\u4e4b\u540e\uff0c\u5b83\u5c31\u4e0d\u518d\u662f\u4e4b\u524d\u7684\u90a3\u4e2a\u53d8\u91cf\uff0c\u6240\u6709\u7684\u64cd\u4f5c\u4e0d\u4f1a\u518d\u5f71\u54cd\u5230\u4e4b\u524d\u7684\u53d8\u91cf\u4e0a<\/li>\n<li>\u5f53\u4f60\u7ed9\u591a\u4e2a\u53d8\u91cf\u8d4b\u503c\u76f8\u540c\u7684\u53d8\u91cf\uff0c\u5b83\u4eec\u5176\u5b9e\u90fd\u662f\u540c\u4e00\u4e2a\uff0c\u53ea\u8981\u6539\u52a8\u5176\u4e2d\u4e4b\u4e00\uff0c\u5176\u4ed6\u7684\u4e5f\u4f1a\u8ddf\u7740\u53d8\u5316\u3002\uff08\u6ce8\u610f\uff0c\u662f\u6539\u52a8\u800c\u975e\u91cd\u65b0\u8d4b\u503c\uff0c\u6bd4\u5982\u4fee\u6539\u5bf9\u8c61\u5c5e\u6027\uff09<\/li>\n<\/ol>\n<p>\u8fd9\u4e2a\u539f\u7406\uff0c\u5728\u6709\u5173<strong>\u51fd\u6570\u7684\u53c2\u6570\u4f20\u9012<\/strong>\u3001<strong>\u62f7\u8d1d\u5bf9\u8c61<\/strong>\u65f6\u90fd\u4f1a\u6d89\u53ca\u5230\u3002<\/p>\n<p>\u56e0\u6b64\uff0c\u56de\u5230\u6700\u521d\u7684\u95ee\u9898\uff0c\u4e09\u4e2a\u91cd\u65b0\u8d4b\u503c\u5176\u5b9e\u672c\u8d28\u662f\u4e09\u4e2a\u5171\u7528\u540c\u4e00\u5730\u5740\u3002<\/p>\n<p>\u672c\u6587\u8f6c\u8f7d\u81ea\u5fae\u4fe1\u516c\u4f17\u53f7&nbsp;<strong>Crossin\u7684\u7f16\u7a0b\u6559\u5ba4<\/strong>&nbsp;\uff0c\u4e3a\u4ee5\u540e\u907f\u514d\u8e29\u5751\u800c\u8bb0\u5f55\u3002<\/p>\n<p>&nbsp;<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u6709\u65f6\u5019\u4e00\u5929\u957f\u7684\u50cf\u4e00\u751f\uff0c<br \/>\u6709\u65f6\u5019\u4e00\u751f\u77ed\u7684\u50cf\u4e00\u5929\u3002<br \/>\u4e16\u754c\u4e0a\u6ca1\u6709\u4e24\u4e2a\u76f8\u540c\u7684\u4e00\u5929\uff0c<br \/>\u4f46\u6bcf\u4e00\u5929\u90fd\u9002\u5408\u5f00\u59cb\uff0c<br \/>\u9002\u5408\u79bb\u522b\uff0c\u9002\u5408\u7231\u3002<\/p>\n<p class=\"has-text-align-right\">\u2014\u2014\u5468\u4e00\u5468\u4e8c<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u591a\u5e74\u5f00\u53d1\u548c\u6559\u5b66 Python \u7684\u8fc7\u7a0b\u4e2d\uff0c\u6709\u4e00\u4e2a bug\uff0c\u51fa\u73b0\u7684\u9891\u7387\u975e\u5e38\u9ad8\uff0c\u7ecf\u5e38\u6709\u4eba\u4f1a\u8e29\u5751\uff1a person = [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1072,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[12,4],"tags":[37,22,15],"_links":{"self":[{"href":"https:\/\/www.yumefx.com\/index.php?rest_route=\/wp\/v2\/posts\/468"}],"collection":[{"href":"https:\/\/www.yumefx.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yumefx.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yumefx.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yumefx.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=468"}],"version-history":[{"count":0,"href":"https:\/\/www.yumefx.com\/index.php?rest_route=\/wp\/v2\/posts\/468\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.yumefx.com\/index.php?rest_route=\/wp\/v2\/media\/1072"}],"wp:attachment":[{"href":"https:\/\/www.yumefx.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=468"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yumefx.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=468"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yumefx.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=468"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}