{"id":899,"date":"2024-11-07T13:31:10","date_gmt":"2024-11-07T05:31:10","guid":{"rendered":"https:\/\/fwq.ai\/blog\/899\/"},"modified":"2024-11-07T13:31:10","modified_gmt":"2024-11-07T05:31:10","slug":"python3-%e4%b8%ad-index-%e6%96%b9%e6%b3%95%ef%bc%9a%e4%b8%ba%e4%bb%80%e4%b9%88-m-index4-4-6-%e8%bf%94%e5%9b%9e%e5%80%bc%e4%b8%ba-5%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/899\/","title":{"rendered":"Python3 \u4e2d `index()` \u65b9\u6cd5\uff1a\u4e3a\u4ec0\u4e48 `m.index(4, 4, 6)` \u8fd4\u56de\u503c\u4e3a 5\uff1f"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1005\" src=\"https:\/\/fwq.ai\/blog\/wp-content\/uploads\/2024\/11\/173054297193246.jpg\" width=\"800\" height=\"320\" srcset=\"https:\/\/fwq.ai\/blog\/wp-content\/uploads\/2024\/11\/173054297193246.jpg 800w, https:\/\/fwq.ai\/blog\/wp-content\/uploads\/2024\/11\/173054297193246-300x120.jpg 300w, https:\/\/fwq.ai\/blog\/wp-content\/uploads\/2024\/11\/173054297193246-768x307.jpg 768w, https:\/\/fwq.ai\/blog\/wp-content\/uploads\/2024\/11\/173054297193246-670x268.jpg 670w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" title=\"Python3 \u4e2d `index()` \u65b9\u6cd5\uff1a\u4e3a\u4ec0\u4e48 `m.index(4, 4, 6)` \u8fd4\u56de\u503c\u4e3a 5\uff1f\u63d2\u56fe\" alt=\"Python3 \u4e2d `index()` \u65b9\u6cd5\uff1a\u4e3a\u4ec0\u4e48 `m.index(4, 4, 6)` \u8fd4\u56de\u503c\u4e3a 5\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>python3 \u4e2d index \u7591\u95ee<\/strong><\/p>\n<p><strong>\u95ee\u9898\uff1a<\/strong><\/p>\n<p>\u5982\u4e0b\u4ee3\u7801\u4e2d\uff0cm.index(4, 4, 6) \u8fd4\u56de\u503c\u4e3a\u4f55\u4e3a 5\uff1f<\/p>\n<pre>m = [1,2,3,4,34,4,5,6]\nn = m.index(4, 4, 6)\nprint(n)<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u56de\u7b54\uff1a<\/strong><\/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>index() \u65b9\u6cd5\u7528\u4e8e\u5728\u6307\u5b9a\u8303\u56f4\u5185\u67e5\u627e\u67d0\u4e2a\u5143\u7d20\u7684\u9996\u6b21\u51fa\u73b0\u7d22\u5f15\u3002\u8be5\u65b9\u6cd5\u6709\u4e09\u4e2a\u53c2\u6570\uff1a<\/p>\n<ul>\n<li>\u8981\u67e5\u627e\u7684\u5143\u7d20<\/li>\n<li>\u53ef\u9009\u7684\u5f00\u59cb\u7d22\u5f15<\/li>\n<li>\u53ef\u9009\u7684\u7ed3\u675f\u7d22\u5f15<\/li>\n<\/ul>\n<p>\u5728\u672c\u4f8b\u4e2d\uff0cm.index(4, 4, 6) \u8868\u793a\u5728\u7d22\u5f15 4 \u5230 6 \u4e4b\u95f4\u67e5\u627e\u5143\u7d20 4\u3002\u7531\u4e8e 4 \u5728\u8be5\u8303\u56f4\u5185\u9996\u6b21\u51fa\u73b0\u5728\u7d22\u5f15 5 \u5904\uff0c\u56e0\u6b64\u8fd4\u56de\u503c\u4e3a 5\u3002<\/p>\n<p>\u6362\u53e5\u8bdd\u8bf4\uff0cindex(4, 4, 6) \u7b49\u4e8e index(4, 4)\uff0c\u5373\u5728\u5217\u8868 m \u4e2d\u4ece\u7d22\u5f15 4 \u5f00\u59cb\u67e5\u627e\u5143\u7d20 4\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fPython3 \u4e2d `index()` \u65b9\u6cd5\uff1a\u4e3a\u4ec0\u4e48 `m.index(4, 4, 6)` \u8fd4\u56de\u503c\u4e3a 5\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>python3 \u4e2d index \u7591\u95ee \u95ee\u9898\uff1a \u5982\u4e0b\u4ee3\u7801\u4e2d\uff0cm.index(4, 4, 6) \u8fd4\u56de\u503c\u4e3a\u4f55\u4e3a 5\uff1f m = [1,2,3,4,34,4,5,6] n = m.index(4, 4, 6) print(n) \u767b\u5f55\u540e\u590d\u5236 \u56de\u7b54\uff1a \u7acb\u5373\u5b66\u4e60\u201cPython\u514d\u8d39\u5b66\u4e60\u7b14\u8bb0\uff08\u6df1\u5165\uff09\u201d\uff1b index() \u65b9\u6cd5\u7528\u4e8e\u5728\u6307\u5b9a\u8303\u56f4\u5185\u67e5\u627e\u67d0\u4e2a\u5143\u7d20\u7684\u9996\u6b21\u51fa\u73b0\u7d22\u5f15\u3002\u8be5\u65b9\u6cd5\u6709\u4e09\u4e2a\u53c2\u6570\uff1a \u8981\u67e5\u627e\u7684\u5143\u7d20 \u53ef\u9009\u7684\u5f00\u59cb\u7d22\u5f15 \u53ef\u9009\u7684\u7ed3\u675f\u7d22\u5f15 \u5728\u672c\u4f8b\u4e2d\uff0cm.index(4, 4, 6) \u8868\u793a\u5728\u7d22\u5f15 4 \u5230 6 \u4e4b\u95f4\u67e5\u627e\u5143\u7d20 4\u3002\u7531\u4e8e 4 \u5728\u8be5\u8303\u56f4\u5185\u9996\u6b21\u51fa\u73b0\u5728\u7d22\u5f15 5 \u5904\uff0c\u56e0\u6b64\u8fd4\u56de\u503c\u4e3a 5\u3002 \u6362\u53e5\u8bdd\u8bf4\uff0cindex(4, 4, 6) \u7b49\u4e8e index(4, 4)\uff0c\u5373\u5728\u5217\u8868 m \u4e2d\u4ece\u7d22\u5f15 4 \u5f00\u59cb\u67e5\u627e\u5143\u7d20 4\u3002 \u4ee5\u4e0a\u5c31\u662fPython3 \u4e2d `index()` [&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-899","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/899","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=899"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/899\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=899"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=899"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=899"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}