{"id":1122768,"date":"2025-01-08T19:24:55","date_gmt":"2025-01-08T11:24:55","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1122768.html"},"modified":"2025-01-08T19:24:57","modified_gmt":"2025-01-08T11:24:57","slug":"%e4%b8%a4%e4%b8%aa%e5%88%97%e8%a1%a8%e5%a6%82%e4%bd%95%e8%bf%9b%e8%a1%8c%e6%af%94%e8%be%83python","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1122768.html","title":{"rendered":"\u4e24\u4e2a\u5217\u8868\u5982\u4f55\u8fdb\u884c\u6bd4\u8f83python"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25084506\/5d54f8a8-193b-482b-ac7a-3dad15f44a70.webp\" alt=\"\u4e24\u4e2a\u5217\u8868\u5982\u4f55\u8fdb\u884c\u6bd4\u8f83python\" \/><\/p>\n<p><p> <strong>\u4e24\u4e2a\u5217\u8868\u8fdb\u884c\u6bd4\u8f83\u7684\u4e3b\u8981\u65b9\u6cd5\u6709\uff1a\u4f7f\u7528\u96c6\u5408\u3001\u5217\u8868\u63a8\u5bfc\u5f0f\u3001\u5185\u7f6e\u51fd\u6570\u3002<\/strong>\u4e0b\u9762\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528\u8fd9\u4e9b\u65b9\u6cd5\u8fdb\u884c\u6bd4\u8f83\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u4f7f\u7528\u96c6\u5408\uff08Set\uff09\u8fdb\u884c\u6bd4\u8f83<\/h3>\n<\/p>\n<p><p>\u4f7f\u7528\u96c6\u5408\u8fdb\u884c\u6bd4\u8f83\u662f\u4e00\u79cd\u9ad8\u6548\u7684\u65b9\u6cd5\uff0c\u56e0\u4e3a\u96c6\u5408\u63d0\u4f9b\u4e86\u8bb8\u591a\u6709\u7528\u7684\u64cd\u4f5c\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u6bd4\u8f83\u4e24\u4e2a\u5217\u8868\u4e2d\u7684\u5143\u7d20\u3002<\/p>\n<\/p>\n<p><h4>\u96c6\u5408\u8fd0\u7b97\u7684\u57fa\u672c\u65b9\u6cd5<\/h4>\n<\/p>\n<p><p>\u96c6\u5408\u53ef\u4ee5\u7528\u6765\u6267\u884c\u5e76\u96c6\u3001\u4ea4\u96c6\u548c\u5dee\u96c6\u7b49\u64cd\u4f5c\uff0c\u8fd9\u4e9b\u64cd\u4f5c\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u5feb\u901f\u6bd4\u8f83\u4e24\u4e2a\u5217\u8868\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">list1 = [1, 2, 3, 4, 5]<\/p>\n<p>list2 = [4, 5, 6, 7, 8]<\/p>\n<h2><strong>\u8f6c\u6362\u4e3a\u96c6\u5408<\/strong><\/h2>\n<p>set1 = set(list1)<\/p>\n<p>set2 = set(list2)<\/p>\n<h2><strong>\u4ea4\u96c6<\/strong><\/h2>\n<p>intersection = set1 &amp; set2<\/p>\n<p>print(&quot;Intersection:&quot;, intersection)<\/p>\n<h2><strong>\u5e76\u96c6<\/strong><\/h2>\n<p>union = set1 | set2<\/p>\n<p>print(&quot;Union:&quot;, union)<\/p>\n<h2><strong>\u5dee\u96c6<\/strong><\/h2>\n<p>difference = set1 - set2<\/p>\n<p>print(&quot;Difference:&quot;, difference)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e9b\u64cd\u4f5c\u975e\u5e38\u9ad8\u6548\uff0c\u5c24\u5176\u662f\u5f53\u5217\u8868\u5143\u7d20\u8f83\u591a\u65f6\u3002<\/p>\n<\/p>\n<p><h4>\u68c0\u67e5\u5217\u8868\u662f\u5426\u76f8\u7b49<\/h4>\n<\/p>\n<p><p>\u6211\u4eec\u53ef\u4ee5\u5229\u7528\u96c6\u5408\u6765\u68c0\u67e5\u4e24\u4e2a\u5217\u8868\u662f\u5426\u5305\u542b\u76f8\u540c\u7684\u5143\u7d20\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def are_lists_equal(list1, list2):<\/p>\n<p>    return set(list1) == set(list2)<\/p>\n<p>list1 = [1, 2, 3, 4, 5]<\/p>\n<p>list2 = [5, 4, 3, 2, 1]<\/p>\n<p>print(&quot;Are lists equal:&quot;, are_lists_equal(list1, list2))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e8c\u3001\u4f7f\u7528\u5217\u8868\u63a8\u5bfc\u5f0f\u8fdb\u884c\u6bd4\u8f83<\/h3>\n<\/p>\n<p><p>\u5217\u8868\u63a8\u5bfc\u5f0f\u662f\u4e00\u79cd\u7b80\u6d01\u800c\u5f3a\u5927\u7684\u8868\u8fbe\u65b9\u5f0f\uff0c\u53ef\u4ee5\u7528\u4e8e\u6bd4\u8f83\u4e24\u4e2a\u5217\u8868\u4e2d\u7684\u5143\u7d20\u3002<\/p>\n<\/p>\n<p><h4>\u627e\u51fa\u4e24\u4e2a\u5217\u8868\u7684\u5171\u540c\u5143\u7d20<\/h4>\n<\/p>\n<p><p>\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u5217\u8868\u63a8\u5bfc\u5f0f\u6765\u627e\u51fa\u4e24\u4e2a\u5217\u8868\u4e2d\u7684\u5171\u540c\u5143\u7d20\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">list1 = [1, 2, 3, 4, 5]<\/p>\n<p>list2 = [4, 5, 6, 7, 8]<\/p>\n<p>common_elements = [element for element in list1 if element in list2]<\/p>\n<p>print(&quot;Common elements:&quot;, common_elements)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u627e\u51fa\u7b2c\u4e00\u4e2a\u5217\u8868\u4e2d\u4e0d\u5728\u7b2c\u4e8c\u4e2a\u5217\u8868\u4e2d\u7684\u5143\u7d20<\/h4>\n<\/p>\n<p><p>\u540c\u6837\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u4f7f\u7528\u5217\u8868\u63a8\u5bfc\u5f0f\u6765\u627e\u51fa\u7b2c\u4e00\u4e2a\u5217\u8868\u4e2d\u4e0d\u5728\u7b2c\u4e8c\u4e2a\u5217\u8868\u4e2d\u7684\u5143\u7d20\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">unique_elements = [element for element in list1 if element not in list2]<\/p>\n<p>print(&quot;Unique elements in list1:&quot;, unique_elements)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e09\u3001\u4f7f\u7528\u5185\u7f6e\u51fd\u6570\u8fdb\u884c\u6bd4\u8f83<\/h3>\n<\/p>\n<p><p>Python \u63d0\u4f9b\u4e86\u4e00\u4e9b\u5185\u7f6e\u51fd\u6570\uff0c\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u65b9\u4fbf\u5730\u6bd4\u8f83\u4e24\u4e2a\u5217\u8868\u3002<\/p>\n<\/p>\n<p><h4>\u4f7f\u7528 <code>all()<\/code> \u548c <code>any()<\/code><\/h4>\n<\/p>\n<p><p><code>all()<\/code> \u51fd\u6570\u53ef\u4ee5\u7528\u4e8e\u68c0\u67e5\u6240\u6709\u5143\u7d20\u662f\u5426\u6ee1\u8db3\u67d0\u4e2a\u6761\u4ef6\uff0c<code>any()<\/code> \u51fd\u6570\u5219\u7528\u4e8e\u68c0\u67e5\u662f\u5426\u6709\u4efb\u610f\u4e00\u4e2a\u5143\u7d20\u6ee1\u8db3\u67d0\u4e2a\u6761\u4ef6\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">list1 = [1, 2, 3, 4, 5]<\/p>\n<p>list2 = [5, 4, 3, 2, 1]<\/p>\n<h2><strong>\u68c0\u67e5\u4e24\u4e2a\u5217\u8868\u662f\u5426\u5305\u542b\u76f8\u540c\u7684\u5143\u7d20<\/strong><\/h2>\n<p>def are_lists_equal(list1, list2):<\/p>\n<p>    return all(element in list2 for element in list1) and all(element in list1 for element in list2)<\/p>\n<p>print(&quot;Are lists equal:&quot;, are_lists_equal(list1, list2))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u4f7f\u7528 <code>Counter<\/code> \u8fdb\u884c\u6bd4\u8f83<\/h4>\n<\/p>\n<p><p><code>collections<\/code> \u6a21\u5757\u4e2d\u7684 <code>Counter<\/code> \u662f\u4e00\u4e2a\u975e\u5e38\u6709\u7528\u7684\u7c7b\uff0c\u53ef\u4ee5\u7528\u4e8e\u7edf\u8ba1\u5143\u7d20\u7684\u51fa\u73b0\u6b21\u6570\uff0c\u4ece\u800c\u65b9\u4fbf\u5730\u6bd4\u8f83\u4e24\u4e2a\u5217\u8868\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from collections import Counter<\/p>\n<p>list1 = [1, 2, 3, 4, 5]<\/p>\n<p>list2 = [5, 4, 3, 2, 1]<\/p>\n<p>def are_lists_equal(list1, list2):<\/p>\n<p>    return Counter(list1) == Counter(list2)<\/p>\n<p>print(&quot;Are lists equal:&quot;, are_lists_equal(list1, list2))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u56db\u3001\u6bd4\u8f83\u5d4c\u5957\u5217\u8868<\/h3>\n<\/p>\n<p><p>\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u6211\u4eec\u6709\u65f6\u9700\u8981\u6bd4\u8f83\u5d4c\u5957\u5217\u8868\uff0c\u5373\u5217\u8868\u4e2d\u7684\u5143\u7d20\u4e5f\u662f\u5217\u8868\u3002<\/p>\n<\/p>\n<p><h4>\u4f7f\u7528\u9012\u5f52\u8fdb\u884c\u6bd4\u8f83<\/h4>\n<\/p>\n<p><p>\u5bf9\u4e8e\u5d4c\u5957\u5217\u8868\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u9012\u5f52\u7684\u65b9\u6cd5\u8fdb\u884c\u6bd4\u8f83\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def are_nested_lists_equal(list1, list2):<\/p>\n<p>    if len(list1) != len(list2):<\/p>\n<p>        return False<\/p>\n<p>    for sublist1, sublist2 in zip(list1, list2):<\/p>\n<p>        if isinstance(sublist1, list) and isinstance(sublist2, list):<\/p>\n<p>            if not are_nested_lists_equal(sublist1, sublist2):<\/p>\n<p>                return False<\/p>\n<p>        elif sublist1 != sublist2:<\/p>\n<p>            return False<\/p>\n<p>    return True<\/p>\n<p>nested_list1 = [[1, 2], [3, 4], [5, 6]]<\/p>\n<p>nested_list2 = [[1, 2], [3, 4], [5, 6]]<\/p>\n<p>print(&quot;Are nested lists equal:&quot;, are_nested_lists_equal(nested_list1, nested_list2))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e94\u3001\u6027\u80fd\u6bd4\u8f83<\/h3>\n<\/p>\n<p><p>\u5728\u9009\u62e9\u6bd4\u8f83\u65b9\u6cd5\u65f6\uff0c\u6027\u80fd\u662f\u4e00\u4e2a\u91cd\u8981\u7684\u8003\u8651\u56e0\u7d20\u3002\u4e0d\u540c\u7684\u65b9\u6cd5\u5728\u4e0d\u540c\u60c5\u51b5\u4e0b\u7684\u6027\u80fd\u8868\u73b0\u53ef\u80fd\u4f1a\u6709\u6240\u4e0d\u540c\u3002<\/p>\n<\/p>\n<p><h4>\u96c6\u5408\u65b9\u6cd5\u7684\u6027\u80fd<\/h4>\n<\/p>\n<p><p>\u96c6\u5408\u65b9\u6cd5\u5728\u5904\u7406\u5927\u89c4\u6a21\u6570\u636e\u65f6\u8868\u73b0\u4f18\u5f02\uff0c\u56e0\u4e3a\u96c6\u5408\u7684\u5e95\u5c42\u5b9e\u73b0\u662f\u54c8\u5e0c\u8868\uff0c\u67e5\u627e\u548c\u6bd4\u8f83\u64cd\u4f5c\u7684\u65f6\u95f4\u590d\u6742\u5ea6\u4e3a O(1)\u3002<\/p>\n<\/p>\n<p><h4>\u5217\u8868\u63a8\u5bfc\u5f0f\u7684\u6027\u80fd<\/h4>\n<\/p>\n<p><p>\u5217\u8868\u63a8\u5bfc\u5f0f\u7684\u6027\u80fd\u53d6\u51b3\u4e8e\u5217\u8868\u7684\u957f\u5ea6\u548c\u5143\u7d20\u7684\u590d\u6742\u6027\u3002\u5bf9\u4e8e\u7b80\u5355\u5143\u7d20\u7684\u5c0f\u578b\u5217\u8868\uff0c\u5217\u8868\u63a8\u5bfc\u5f0f\u7684\u6027\u80fd\u901a\u5e38\u8f83\u597d\u3002<\/p>\n<\/p>\n<p><h4>\u5185\u7f6e\u51fd\u6570\u7684\u6027\u80fd<\/h4>\n<\/p>\n<p><p>\u5185\u7f6e\u51fd\u6570\u901a\u5e38\u7ecf\u8fc7\u4f18\u5316\uff0c\u5728\u5927\u591a\u6570\u60c5\u51b5\u4e0b\u6027\u80fd\u8f83\u597d\u3002\u5c24\u5176\u662f <code>Counter<\/code> \u7c7b\uff0c\u5728\u5904\u7406\u5927\u91cf\u91cd\u590d\u5143\u7d20\u65f6\u6027\u80fd\u4f18\u5f02\u3002<\/p>\n<\/p>\n<p><h3>\u516d\u3001\u5b9e\u9645\u5e94\u7528\u573a\u666f<\/h3>\n<\/p>\n<p><h4>\u6570\u636e\u53bb\u91cd<\/h4>\n<\/p>\n<p><p>\u5728\u5904\u7406\u6570\u636e\u65f6\uff0c\u6211\u4eec\u7ecf\u5e38\u9700\u8981\u53bb\u91cd\u3002\u4f7f\u7528\u96c6\u5408\u53ef\u4ee5\u65b9\u4fbf\u5730\u53bb\u9664\u91cd\u590d\u5143\u7d20\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">data = [1, 2, 2, 3, 4, 4, 5]<\/p>\n<p>unique_data = list(set(data))<\/p>\n<p>print(&quot;Unique data:&quot;, unique_data)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u6570\u636e\u8fc7\u6ee4<\/h4>\n<\/p>\n<p><p>\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u5217\u8868\u63a8\u5bfc\u5f0f\u6765\u8fc7\u6ee4\u6570\u636e\uff0c\u6839\u636e\u7279\u5b9a\u6761\u4ef6\u7b5b\u9009\u51fa\u7b26\u5408\u6761\u4ef6\u7684\u5143\u7d20\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]<\/p>\n<p>filtered_data = [x for x in data if x % 2 == 0]<\/p>\n<p>print(&quot;Filtered data:&quot;, filtered_data)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u6570\u636e\u5408\u5e76<\/h4>\n<\/p>\n<p><p>\u5728\u5904\u7406\u591a\u4e2a\u6570\u636e\u6e90\u65f6\uff0c\u6211\u4eec\u53ef\u80fd\u9700\u8981\u5408\u5e76\u6570\u636e\u3002\u4f7f\u7528\u96c6\u5408\u53ef\u4ee5\u65b9\u4fbf\u5730\u5408\u5e76\u591a\u4e2a\u5217\u8868\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">list1 = [1, 2, 3]<\/p>\n<p>list2 = [4, 5, 6]<\/p>\n<p>merged_list = list(set(list1) | set(list2))<\/p>\n<p>print(&quot;Merged list:&quot;, merged_list)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e03\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u6bd4\u8f83\u4e24\u4e2a\u5217\u8868\u7684\u65b9\u6cd5\u6709\u5f88\u591a\uff0c\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\u53d6\u51b3\u4e8e\u5177\u4f53\u7684\u5e94\u7528\u573a\u666f\u548c\u6027\u80fd\u9700\u6c42\u3002<strong>\u4f7f\u7528\u96c6\u5408\u8fdb\u884c\u6bd4\u8f83\u3001\u5217\u8868\u63a8\u5bfc\u5f0f\u3001\u5185\u7f6e\u51fd\u6570\u90fd\u662f\u5e38\u89c1\u4e14\u6709\u6548\u7684\u65b9\u6cd5<\/strong>\u3002\u5728\u5904\u7406\u5d4c\u5957\u5217\u8868\u65f6\uff0c\u9012\u5f52\u65b9\u6cd5\u662f\u4e00\u4e2a\u6709\u6548\u7684\u9009\u62e9\u3002\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u5e94\u8be5\u6839\u636e\u6570\u636e\u7684\u7279\u70b9\u548c\u6027\u80fd\u8981\u6c42\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\uff0c\u4ee5\u8fbe\u5230\u6700\u4f73\u6548\u679c\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u6bd4\u8f83\u4e24\u4e2a\u5217\u8868\u4ee5\u67e5\u627e\u76f8\u540c\u7684\u5143\u7d20\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u96c6\u5408\uff08set\uff09\u6765\u9ad8\u6548\u5730\u6bd4\u8f83\u4e24\u4e2a\u5217\u8868\u5e76\u67e5\u627e\u76f8\u540c\u7684\u5143\u7d20\u3002\u901a\u8fc7\u5c06\u4e24\u4e2a\u5217\u8868\u8f6c\u6362\u4e3a\u96c6\u5408\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ea4\u96c6\u64cd\u4f5c\u7b26\uff08&amp;\uff09\u6765\u83b7\u53d6\u4e24\u4e2a\u5217\u8868\u4e2d\u5171\u6709\u7684\u5143\u7d20\u3002\u4f8b\u5982\uff1a  <\/p>\n<pre><code class=\"language-python\">list1 = [1, 2, 3, 4]\nlist2 = [3, 4, 5, 6]\ncommon_elements = set(list1) &amp; set(list2)\nprint(common_elements)  # \u8f93\u51fa: {3, 4}\n<\/code><\/pre>\n<p>\u8fd9\u79cd\u65b9\u6cd5\u4e0d\u4ec5\u7b80\u5355\u6613\u61c2\uff0c\u800c\u4e14\u6027\u80fd\u4f18\u8d8a\uff0c\u9002\u7528\u4e8e\u5927\u89c4\u6a21\u6570\u636e\u7684\u6bd4\u8f83\u3002<\/p>\n<p><strong>\u5982\u679c\u60f3\u8981\u6bd4\u8f83\u4e24\u4e2a\u5217\u8868\u5e76\u627e\u51fa\u4e0d\u540c\u7684\u5143\u7d20\uff0c\u8be5\u600e\u4e48\u505a\uff1f<\/strong><br \/>\u8981\u627e\u51fa\u4e24\u4e2a\u5217\u8868\u4e2d\u4e0d\u540c\u7684\u5143\u7d20\uff0c\u53ef\u4ee5\u4f7f\u7528\u96c6\u5408\u7684\u5dee\u96c6\u64cd\u4f5c\u3002\u901a\u8fc7\u5c06\u4e00\u4e2a\u5217\u8868\u8f6c\u6362\u4e3a\u96c6\u5408\uff0c\u7136\u540e\u4f7f\u7528\u5dee\u96c6\u64cd\u4f5c\u7b26\uff08-\uff09\uff0c\u53ef\u4ee5\u8f7b\u677e\u83b7\u5f97\u5728\u4e00\u4e2a\u5217\u8868\u4e2d\u4f46\u4e0d\u5728\u53e6\u4e00\u4e2a\u5217\u8868\u4e2d\u7684\u5143\u7d20\u3002\u4f8b\u5982\uff1a  <\/p>\n<pre><code class=\"language-python\">list1 = [1, 2, 3, 4]\nlist2 = [3, 4, 5, 6]\nunique_to_list1 = set(list1) - set(list2)\nunique_to_list2 = set(list2) - set(list1)\nprint(unique_to_list1)  # \u8f93\u51fa: {1, 2}\nprint(unique_to_list2)  # \u8f93\u51fa: {5, 6}\n<\/code><\/pre>\n<p>\u8fd9\u79cd\u65b9\u5f0f\u80fd\u591f\u6e05\u6670\u5730\u663e\u793a\u4e24\u4e2a\u5217\u8868\u4e4b\u95f4\u7684\u5dee\u5f02\u3002<\/p>\n<p><strong>\u5982\u4f55\u6bd4\u8f83\u4e24\u4e2a\u5217\u8868\u4ee5\u786e\u4fdd\u5b83\u4eec\u7684\u5185\u5bb9\u5b8c\u5168\u76f8\u540c\uff1f<\/strong><br \/>\u8981\u68c0\u67e5\u4e24\u4e2a\u5217\u8868\u662f\u5426\u5185\u5bb9\u5b8c\u5168\u76f8\u540c\uff0c\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\u201c==\u201d\u8fd0\u7b97\u7b26\u3002\u5b83\u4f1a\u6bd4\u8f83\u4e24\u4e2a\u5217\u8868\u4e2d\u7684\u5143\u7d20\u53ca\u5176\u987a\u5e8f\u3002\u5982\u679c\u4e24\u4e2a\u5217\u8868\u7684\u5143\u7d20\u548c\u987a\u5e8f\u90fd\u4e00\u81f4\uff0c\u5219\u8fd4\u56deTrue\uff0c\u5426\u5219\u8fd4\u56deFalse\u3002\u4f8b\u5982\uff1a  <\/p>\n<pre><code class=\"language-python\">list1 = [1, 2, 3]\nlist2 = [1, 2, 3]\nlist3 = [3, 2, 1]\nprint(list1 == list2)  # \u8f93\u51fa: True\nprint(list1 == list3)  # \u8f93\u51fa: False\n<\/code><\/pre>\n<p>\u8fd9\u79cd\u65b9\u6cd5\u7b80\u5355\u5feb\u6377\uff0c\u9002\u5408\u7528\u4e8e\u68c0\u67e5\u5217\u8868\u7684\u5b8c\u6574\u4e00\u81f4\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u4e24\u4e2a\u5217\u8868\u8fdb\u884c\u6bd4\u8f83\u7684\u4e3b\u8981\u65b9\u6cd5\u6709\uff1a\u4f7f\u7528\u96c6\u5408\u3001\u5217\u8868\u63a8\u5bfc\u5f0f\u3001\u5185\u7f6e\u51fd\u6570\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528\u8fd9\u4e9b\u65b9\u6cd5\u8fdb\u884c\u6bd4\u8f83\u3002 \u4e00\u3001\u4f7f [&hellip;]","protected":false},"author":3,"featured_media":1122770,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1122768"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=1122768"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1122768\/revisions"}],"predecessor-version":[{"id":1122771,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1122768\/revisions\/1122771"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1122770"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1122768"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1122768"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1122768"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}