{"id":175677,"date":"2022-04-14T04:25:14","date_gmt":"2022-04-13T20:25:14","guid":{"rendered":"http:\/\/www.idc.net\/help\/175677\/"},"modified":"2022-04-14T04:25:14","modified_gmt":"2022-04-13T20:25:14","slug":"%e5%90%8e%e6%b5%aa%e4%ba%91python%e6%95%99%e7%a8%8b%ef%bc%9apython%e5%88%97%e8%a1%a8%e6%9c%89%e5%93%aa%e4%ba%9b%e7%89%b9%e7%82%b9","status":"publish","type":"post","link":"https:\/\/idc.net\/help\/175677\/","title":{"rendered":"\u540e\u6d6a\u4e91Python\u6559\u7a0b\uff1apython\u5217\u8868\u6709\u54ea\u4e9b\u7279\u70b9"},"content":{"rendered":"<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/oss.py.cn\/pycn\/upload\/image\/445\/264\/735\/1621926108920513.png\" class=\"aligncenter\"><\/p>\n<p><strong>\u8bf4\u660e<\/strong><\/p>\n<p>1\u3001\u5217\u8868\u7531\u4e00\u4e2a\u6216\u8005\u591a\u4e2a\u6570\u636e\u6784\u6210\uff0c\u6570\u636e\u7684\u7c7b\u578b\u53ef\u4ee5\u4e0d\u76f8\u540c\u4e5f\u53ef\u4ee5\u76f8\u540c\u3002<\/p>\n<p>2\u3001\u5217\u8868\u4e2d\u7684\u6570\u636e\u9700\u8981\u5199\u5728[]\u4e2d\u62ec\u53f7\u5185\u90e8\uff0c\u6570\u636e\u4e0e\u6570\u636e\u4e4b\u95f4\u7528\u9017\u53f7\u9694\u5f00\u3002<\/p>\n<p>3\u3001\u662f\u4e00\u4e2a\u6709\u5e8f\u7684\u96c6\u5408\u3002<\/p>\n<p>\u4e0b\u6807\u7d22\u5f15\u9ed8\u8ba4\u91cd 0 \u5f00\u59cb\uff0c\u548c\u5b57\u7b26\u4e32\u7c7b\u4f3c\u3002<\/p>\n<p><strong>\u5b9e\u4f8b<\/strong><\/p>\n<pre>#&nbsp;!usr\/bin\/env&nbsp;python\n#&nbsp;-*-&nbsp;coding:utf-8&nbsp;_*-\n\"\"\"\n@Author:\u733f\u8bf4\u7f16\u7a0b\n@Blog(\u4e2a\u4eba\u535a\u5ba2\u5730\u5740):&nbsp;www.codersrc.com\n@File:python\u5217\u8868list.py\n@Time:2021\/3\/22&nbsp;00:37\n@Motto:\u4e0d\u79ef\u8dec\u6b65\u65e0\u4ee5\u81f3\u5343\u91cc\uff0c\u4e0d\u79ef\u5c0f\u6d41\u65e0\u4ee5\u6210\u6c5f\u6d77\uff0c\u7a0b\u5e8f\u4eba\u751f\u7684\u7cbe\u5f69\u9700\u8981\u575a\u6301\u4e0d\u61c8\u5730\u79ef\u7d2f\uff01\n&nbsp;\n\"\"\"\n&nbsp;\n&nbsp;\nlist1&nbsp;=&nbsp;list()&nbsp;#\u5b9a\u4e49\u4e00\u4e2a\u7a7a\u5217\u8868\nprint(\"list1&nbsp;:\",list1)\nlist2&nbsp;=&nbsp;[1,2,3,4]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#\u5b9a\u4e49\u4e00\u4e2a\u6574\u6570\u7c7b\u578b\u7684\u5217\u8868\u8d4b\u503c\u7ed9list2\nprint(\"list2&nbsp;:&nbsp;%s\"&nbsp;%&nbsp;list2)\nlist3&nbsp;=&nbsp;[\"a\",\"b\",\"c\"]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#\u5b9a\u4e49\u4e00\u4e2a\u5b57\u7b26\u4e32\u7c7b\u578b\u7684\u5217\u8868\u8d4b\u503c\u7ed9list3\nprint(\"list3&nbsp;:&nbsp;{}\"&nbsp;.format(list3))\nlist4&nbsp;=&nbsp;[0,\"hello\",True]&nbsp;&nbsp;&nbsp;&nbsp;#\u5b9a\u4e49\u4e00\u4e2a\u4e0d\u540c\u6570\u636e\u7c7b\u578b\u7684\u5217\u8868\u8d4b\u503c\u7ed9list4\nprint(\"list4&nbsp;:&nbsp;{0}\"&nbsp;.format(list4))\n&nbsp;\n'''\n\u8f93\u51fa\u7ed3\u679c\uff1a\nlist1&nbsp;:&nbsp;[]\nlist2&nbsp;:&nbsp;[1,&nbsp;2,&nbsp;3,&nbsp;4]\nlist3&nbsp;:&nbsp;['a',&nbsp;'b',&nbsp;'c']\nlist4&nbsp;:&nbsp;[0,&nbsp;'hello',&nbsp;True]\n&nbsp;\n'''<\/pre>\n<p>\u4ee5\u4e0a\u5c31\u662fpython\u5217\u8868\u7684\u7279\u70b9\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u6709\u6240\u5e2e\u52a9\u3002<span>\u66f4\u591aPython\u5b66\u4e60\u6307\u8def\uff1a<\/span>\u540e\u6d6a\u4e91python\u6559\u7a0b<br \/><strong><\/strong><\/p>\n<p><span style=\"font-size: 14px\">\u672c\u6587\u6559\u7a0b\u64cd\u4f5c\u73af\u5883\uff1awindows7\u7cfb\u7edf\u3001Python 3.9.1\uff0cDELL G3\u7535\u8111\u3002<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8bf4\u660e 1\u3001\u5217\u8868\u7531\u4e00\u4e2a\u6216\u8005\u591a\u4e2a\u6570\u636e\u6784\u6210\uff0c\u6570\u636e\u7684\u7c7b\u578b\u53ef\u4ee5\u4e0d\u76f8\u540c\u4e5f\u53ef\u4ee5\u76f8\u540c\u3002 2\u3001\u5217\u8868\u4e2d\u7684\u6570\u636e\u9700\u8981\u5199\u5728[]\u4e2d\u62ec\u53f7\u5185\u90e8 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":175678,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[182397],"tags":[],"class_list":["post-175677","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python"],"_links":{"self":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/175677","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/comments?post=175677"}],"version-history":[{"count":0,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/175677\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media\/175678"}],"wp:attachment":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media?parent=175677"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/categories?post=175677"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/tags?post=175677"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}