{"id":49839,"date":"2024-12-03T16:21:28","date_gmt":"2024-12-03T08:21:28","guid":{"rendered":"https:\/\/fwq.ai\/blog\/49839\/"},"modified":"2024-12-03T16:21:28","modified_gmt":"2024-12-03T08:21:28","slug":"python-%e4%b8%ad%e7%9a%84-%e5%92%8c-none-%e6%9c%89%e4%bb%80%e4%b9%88%e5%8c%ba%e5%88%ab%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/49839\/","title":{"rendered":"Python \u4e2d\u7684 `[]` \u548c `None` \u6709\u4ec0\u4e48\u533a\u522b\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>Python \u4e2d\u7684 `[]` \u548c `None` \u6709\u4ec0\u4e48\u533a\u522b\uff1f<\/h1>\n<p>\u5c0f\u4f19\u4f34\u4eec\u5bf9\u6587\u7ae0\u7f16\u7a0b\u611f\u5174\u8da3\u5417\uff1f\u662f\u5426\u6b63\u5728\u5b66\u4e60\u76f8\u5173\u77e5\u8bc6\u70b9\uff1f\u5982\u679c\u662f\uff0c\u90a3\u4e48\u672c\u6587\u300aPython \u4e2d\u7684 `[]` \u548c `None` \u6709\u4ec0\u4e48\u533a\u522b\uff1f\u300b\uff0c\u5c31\u5f88\u9002\u5408\u4f60\uff0c\u672c\u7bc7\u6587\u7ae0\u8bb2\u89e3\u7684\u77e5\u8bc6\u70b9\u4e3b\u8981\u5305\u62ec\u3002\u5728\u4e4b\u540e\u7684\u6587\u7ae0\u4e2d\u4e5f\u4f1a\u591a\u591a\u5206\u4eab\u76f8\u5173\u77e5\u8bc6\u70b9\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u7684\u77e5\u8bc6\u79ef\u7d2f\u6709\u6240\u5e2e\u52a9\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241105\/17307835476729a93bae680.jpg\" class=\"aligncenter\" title=\"Python \u4e2d\u7684 `[]` \u548c `None` \u6709\u4ec0\u4e48\u533a\u522b\uff1f\u63d2\u56fe\" alt=\"Python \u4e2d\u7684 `[]` \u548c `None` \u6709\u4ec0\u4e48\u533a\u522b\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>Python\u4e2d\u7684None<\/strong><\/p>\n<p>\u5728Python\u4e2d\uff0c\u6570\u7ec4\u53ef\u4ee5\u521b\u5efa\u4e3a\u7a7a\u5217\u8868\uff0c\u4e5f\u53ef\u4ee5\u8d4b\u503cNone\u3002\u4e86\u89e3\u8fd9\u4e24\u4e2a\u64cd\u4f5c\u4e4b\u95f4\u7684\u533a\u522b\u81f3\u5173\u91cd\u8981\u3002<\/p>\n<p><strong>array = []<\/strong><\/p>\n<ul>\n<li>\u521b\u5efa\u4e00\u4e2a\u7a7a\u5217\u8868<\/li>\n<li>\u53ef\u4ee5\u4f7f\u7528\u5217\u8868\u65b9\u6cd5\u64cd\u4f5c<\/li>\n<li>\u9ed8\u8ba4\u503c\u4e3a\u7a7a\u5143\u7ec4()<\/li>\n<\/ul>\n<p><strong>array = None<\/strong><\/p>\n<ul>\n<li>\u8d4b\u503c\u4e3aNoneType\u7c7b\u578b<\/li>\n<li>\u4e0d\u662f\u4e00\u4e2a\u5217\u8868<\/li>\n<li>\u4e0d\u80fd\u4f7f\u7528\u5217\u8868\u65b9\u6cd5<\/li>\n<li>\u9ed8\u8ba4\u503c\u4e3a\u7a7a\u503c<\/li>\n<\/ul>\n<p>\u56e0\u6b64\uff0c<strong>array = []<\/strong>\u6307\u5411\u4e00\u4e2a\u7a7a\u5217\u8868\uff0c\u800c<strong>array = None<\/strong>\u6307\u5411\u4e00\u4e2a\u7a7a\u503c\uff0c\u6ca1\u6709\u4efb\u4f55\u5143\u7d20\u6216\u65b9\u6cd5\u3002<\/p>\n<p>\u4eca\u5929\u5e26\u5927\u5bb6\u4e86\u89e3\u4e86\u7684\u76f8\u5173\u77e5\u8bc6\uff0c\u5e0c\u671b\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\uff1b\u5173\u4e8e\u6587\u7ae0\u7684\u6280\u672f\u77e5\u8bc6\u6211\u4eec\u4f1a\u4e00\u70b9\u70b9\u6df1\u5165\u4ecb\u7ecd\uff0c\u6b22\u8fce\u5927\u5bb6\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff0c\u4e00\u8d77\u5b66\u4e60\u7f16\u7a0b~<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Python \u4e2d\u7684 `[]` \u548c `None` \u6709\u4ec0\u4e48\u533a\u522b\uff1f \u5c0f\u4f19\u4f34\u4eec\u5bf9\u6587\u7ae0\u7f16\u7a0b\u611f\u5174\u8da3\u5417\uff1f\u662f\u5426\u6b63\u5728\u5b66\u4e60\u76f8\u5173\u77e5\u8bc6\u70b9\uff1f\u5982\u679c\u662f\uff0c\u90a3\u4e48\u672c\u6587\u300aPython \u4e2d\u7684 `[]` \u548c `None` \u6709\u4ec0\u4e48\u533a\u522b\uff1f\u300b\uff0c\u5c31\u5f88\u9002\u5408\u4f60\uff0c\u672c\u7bc7\u6587\u7ae0\u8bb2\u89e3\u7684\u77e5\u8bc6\u70b9\u4e3b\u8981\u5305\u62ec\u3002\u5728\u4e4b\u540e\u7684\u6587\u7ae0\u4e2d\u4e5f\u4f1a\u591a\u591a\u5206\u4eab\u76f8\u5173\u77e5\u8bc6\u70b9\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u7684\u77e5\u8bc6\u79ef\u7d2f\u6709\u6240\u5e2e\u52a9\uff01 Python\u4e2d\u7684None \u5728Python\u4e2d\uff0c\u6570\u7ec4\u53ef\u4ee5\u521b\u5efa\u4e3a\u7a7a\u5217\u8868\uff0c\u4e5f\u53ef\u4ee5\u8d4b\u503cNone\u3002\u4e86\u89e3\u8fd9\u4e24\u4e2a\u64cd\u4f5c\u4e4b\u95f4\u7684\u533a\u522b\u81f3\u5173\u91cd\u8981\u3002 array = [] \u521b\u5efa\u4e00\u4e2a\u7a7a\u5217\u8868 \u53ef\u4ee5\u4f7f\u7528\u5217\u8868\u65b9\u6cd5\u64cd\u4f5c \u9ed8\u8ba4\u503c\u4e3a\u7a7a\u5143\u7ec4() array = None \u8d4b\u503c\u4e3aNoneType\u7c7b\u578b \u4e0d\u662f\u4e00\u4e2a\u5217\u8868 \u4e0d\u80fd\u4f7f\u7528\u5217\u8868\u65b9\u6cd5 \u9ed8\u8ba4\u503c\u4e3a\u7a7a\u503c \u56e0\u6b64\uff0carray = []\u6307\u5411\u4e00\u4e2a\u7a7a\u5217\u8868\uff0c\u800carray = None\u6307\u5411\u4e00\u4e2a\u7a7a\u503c\uff0c\u6ca1\u6709\u4efb\u4f55\u5143\u7d20\u6216\u65b9\u6cd5\u3002 \u4eca\u5929\u5e26\u5927\u5bb6\u4e86\u89e3\u4e86\u7684\u76f8\u5173\u77e5\u8bc6\uff0c\u5e0c\u671b\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\uff1b\u5173\u4e8e\u6587\u7ae0\u7684\u6280\u672f\u77e5\u8bc6\u6211\u4eec\u4f1a\u4e00\u70b9\u70b9\u6df1\u5165\u4ecb\u7ecd\uff0c\u6b22\u8fce\u5927\u5bb6\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff0c\u4e00\u8d77\u5b66\u4e60\u7f16\u7a0b~<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-49839","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/49839","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=49839"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/49839\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=49839"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=49839"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=49839"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}