{"id":862,"date":"2024-11-07T09:08:06","date_gmt":"2024-11-07T01:08:06","guid":{"rendered":"https:\/\/fwq.ai\/blog\/862\/"},"modified":"2024-11-07T09:08:06","modified_gmt":"2024-11-07T01:08:06","slug":"python-%e4%b8%ad%e7%9a%84-none-%e5%92%8c-%e7%a9%ba%e5%88%97%e8%a1%a8-%ef%bc%9a%e5%a6%82%e4%bd%95%e9%80%89%e6%8b%a9%e5%90%88%e9%80%82%e7%9a%84%e7%a9%ba%e5%80%bc%e8%a1%a8%e7%a4%ba%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/862\/","title":{"rendered":"Python \u4e2d\u7684 None \u548c \u7a7a\u5217\u8868 []\uff1a\u5982\u4f55\u9009\u62e9\u5408\u9002\u7684\u7a7a\u503c\u8868\u793a\uff1f"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1051\" src=\"https:\/\/fwq.ai\/blog\/wp-content\/uploads\/2024\/11\/173018521097027.jpg\" width=\"800\" height=\"320\" srcset=\"https:\/\/fwq.ai\/blog\/wp-content\/uploads\/2024\/11\/173018521097027.jpg 800w, https:\/\/fwq.ai\/blog\/wp-content\/uploads\/2024\/11\/173018521097027-300x120.jpg 300w, https:\/\/fwq.ai\/blog\/wp-content\/uploads\/2024\/11\/173018521097027-768x307.jpg 768w, https:\/\/fwq.ai\/blog\/wp-content\/uploads\/2024\/11\/173018521097027-670x268.jpg 670w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" title=\"Python \u4e2d\u7684 None \u548c \u7a7a\u5217\u8868 []\uff1a\u5982\u4f55\u9009\u62e9\u5408\u9002\u7684\u7a7a\u503c\u8868\u793a\uff1f\u63d2\u56fe\" alt=\"Python \u4e2d\u7684 None \u548c \u7a7a\u5217\u8868 []\uff1a\u5982\u4f55\u9009\u62e9\u5408\u9002\u7684\u7a7a\u503c\u8868\u793a\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>python \u4e2d\u7279\u6b8a\u503c none \u7684\u4e0d\u540c\u5e94\u7528<\/strong><\/p>\n<p>\u5728 python \u4e2d\uff0c\u4f7f\u7528 none \u8868\u793a\u7a7a\u503c\u6216\u4e0d\u5b58\u5728\u7684\u503c\u3002\u5728\u4ee5\u4e0b\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u63a2\u8ba8\u4e86 none \u4e0e\u7a7a\u5217\u8868 [] \u4e4b\u95f4\u7684\u533a\u522b\uff1a<\/p>\n<pre>array1 = []\narray2 = None<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>array = []\uff1a\u7a7a\u5217\u8868<\/strong><\/p>\n<p>array1 \u5f15\u7528\u4e86\u4e00\u4e2a\u7a7a\u5217\u8868\uff0c\u5b83\u4e0d\u5305\u542b\u4efb\u4f55\u5143\u7d20\u3002\u7a7a\u5217\u8868\u5177\u6709 list \u7684\u6240\u6709\u65b9\u6cd5\uff0c\u4f8b\u5982 append() \u548c len().<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201cPython\u514d\u8d39\u5b66\u4e60\u7b14\u8bb0\uff08\u6df1\u5165\uff09\u201d\uff1b<\/p>\n<p><strong>array = none\uff1anonetype \u503c<\/strong><\/p>\n<p>array2 \u5f15\u7528\u4e86\u7279\u6b8a\u503c none\uff0c\u5b83\u8868\u793a\u7a7a\u6216\u4e0d\u5b58\u5728\u3002nonetype \u662f\u4e00\u79cd\u7279\u6b8a\u7684\u7c7b\u578b\uff0c\u4e0d\u5c5e\u4e8e\u4efb\u4f55\u5176\u4ed6\u7c7b\u578b\u3002\u5b83\u6ca1\u6709\u65b9\u6cd5\u6216\u5c5e\u6027\uff0c\u4e5f\u4e0d\u63a5\u53d7\u4efb\u4f55\u64cd\u4f5c\u3002<\/p>\n<p><strong>\u533a\u522b\uff1a<\/strong><\/p>\n<table>\n<thead>\n<tr>\n<th>\u7279\u5f81<\/th>\n<th>[] (\u7a7a\u5217\u8868)<\/th>\n<th>none<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\u6570\u636e\u7c7b\u578b<\/td>\n<td>list<\/td>\n<td>nonetype<\/td>\n<\/tr>\n<tr>\n<td>\u65b9\u6cd5\u6216\u5c5e\u6027<\/td>\n<td>\u53ef\u7528<\/td>\n<td>\u4e0d\u53ef\u7528<\/td>\n<\/tr>\n<tr>\n<td>\u503c<\/td>\n<td>\u7a7a<\/td>\n<td>\u7a7a\u6216\u4e0d\u5b58\u5728<\/td>\n<\/tr>\n<tr>\n<td>\u6bd4\u8f83<\/td>\n<td>\u4ec5\u4e0e\u81ea\u8eab\u76f8\u7b49 ([])<\/td>\n<td>\u4e0e\u9664\u6570\u5b57\u5916\u7684\u6240\u6709\u503c\u4e0d\u7b49<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u56e0\u6b64\uff0c\u7a7a\u5217\u8868\u53ef\u7528\u6765\u5b58\u50a8\u5143\u7d20\u5e76\u8fdb\u884c\u5217\u8868\u64cd\u4f5c\uff0c\u800c none \u8868\u793a\u4e0d\u5b58\u5728\u7684\u503c\u6216\u4f5c\u4e3a\u5360\u4f4d\u7b26\u3002\u9009\u62e9\u54ea\u79cd\u7528\u6cd5\u53d6\u51b3\u4e8e\u7279\u5b9a\u7684\u7528\u4f8b\uff1a<\/p>\n<ul>\n<li>\u5982\u679c\u9700\u8981\u4e00\u4e2a\u53ef\u4ee5\u5bb9\u7eb3\u5143\u7d20\u5e76\u8fdb\u884c\u5217\u8868\u64cd\u4f5c\u7684\u5bb9\u5668\uff0c\u8bf7\u4f7f\u7528 [].<\/li>\n<li>\u5982\u679c\u9700\u8981\u8868\u793a\u7a7a\u503c\u6216\u4e0d\u5b58\u5728\uff0c\u8bf7\u4f7f\u7528 none\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662fPython \u4e2d\u7684 None \u548c \u7a7a\u5217\u8868 []\uff1a\u5982\u4f55\u9009\u62e9\u5408\u9002\u7684\u7a7a\u503c\u8868\u793a\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>python \u4e2d\u7279\u6b8a\u503c none \u7684\u4e0d\u540c\u5e94\u7528 \u5728 python \u4e2d\uff0c\u4f7f\u7528 none \u8868\u793a\u7a7a\u503c\u6216\u4e0d\u5b58\u5728\u7684\u503c\u3002\u5728\u4ee5\u4e0b\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u63a2\u8ba8\u4e86 none \u4e0e\u7a7a\u5217\u8868 [] \u4e4b\u95f4\u7684\u533a\u522b\uff1a array1 = [] array2 = None \u767b\u5f55\u540e\u590d\u5236 array = []\uff1a\u7a7a\u5217\u8868 array1 \u5f15\u7528\u4e86\u4e00\u4e2a\u7a7a\u5217\u8868\uff0c\u5b83\u4e0d\u5305\u542b\u4efb\u4f55\u5143\u7d20\u3002\u7a7a\u5217\u8868\u5177\u6709 list \u7684\u6240\u6709\u65b9\u6cd5\uff0c\u4f8b\u5982 append() \u548c len(). \u7acb\u5373\u5b66\u4e60\u201cPython\u514d\u8d39\u5b66\u4e60\u7b14\u8bb0\uff08\u6df1\u5165\uff09\u201d\uff1b array = none\uff1anonetype \u503c array2 \u5f15\u7528\u4e86\u7279\u6b8a\u503c none\uff0c\u5b83\u8868\u793a\u7a7a\u6216\u4e0d\u5b58\u5728\u3002nonetype \u662f\u4e00\u79cd\u7279\u6b8a\u7684\u7c7b\u578b\uff0c\u4e0d\u5c5e\u4e8e\u4efb\u4f55\u5176\u4ed6\u7c7b\u578b\u3002\u5b83\u6ca1\u6709\u65b9\u6cd5\u6216\u5c5e\u6027\uff0c\u4e5f\u4e0d\u63a5\u53d7\u4efb\u4f55\u64cd\u4f5c\u3002 \u533a\u522b\uff1a \u7279\u5f81 [] (\u7a7a\u5217\u8868) none \u6570\u636e\u7c7b\u578b list nonetype \u65b9\u6cd5\u6216\u5c5e\u6027 \u53ef\u7528 \u4e0d\u53ef\u7528 \u503c \u7a7a \u7a7a\u6216\u4e0d\u5b58\u5728 \u6bd4\u8f83 \u4ec5\u4e0e\u81ea\u8eab\u76f8\u7b49 [&hellip;]<\/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-862","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/862","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=862"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/862\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=862"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=862"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=862"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}