{"id":1065864,"date":"2024-12-31T16:21:17","date_gmt":"2024-12-31T08:21:17","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1065864.html"},"modified":"2024-12-31T16:21:19","modified_gmt":"2024-12-31T08:21:19","slug":"python%e4%b8%ad%e5%a6%82%e4%bd%95%e5%bb%ba%e7%ab%8b%e4%b8%a4%e4%b8%aa%e5%88%97%e8%a1%a8","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1065864.html","title":{"rendered":"python\u4e2d\u5982\u4f55\u5efa\u7acb\u4e24\u4e2a\u5217\u8868"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2024\/12\/91289a77-c5f3-45a6-a46d-18f0922abb87.webp?x-oss-process=image\/auto-orient,1\/format,webp\" alt=\"python\u4e2d\u5982\u4f55\u5efa\u7acb\u4e24\u4e2a\u5217\u8868\" \/><\/p>\n<p><p> <strong>\u5728Python\u4e2d\uff0c\u5efa\u7acb\u4e24\u4e2a\u5217\u8868\u53ef\u4ee5\u901a\u8fc7\u7b80\u5355\u7684\u8d4b\u503c\u64cd\u4f5c\u3001\u5217\u8868\u63a8\u5bfc\u5f0f\u4ee5\u53ca\u4f7f\u7528\u5185\u7f6e\u51fd\u6570\u7b49\u65b9\u5f0f\u5b9e\u73b0\u3002<\/strong> \u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5\u6765\u521b\u5efa\u4e24\u4e2a\u5217\u8868\uff1a1. \u76f4\u63a5\u8d4b\u503c\u30012. \u4f7f\u7528\u5217\u8868\u63a8\u5bfc\u5f0f\u30013. \u4f7f\u7528\u5185\u7f6e\u51fd\u6570\u3002\u63a5\u4e0b\u6765\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u76f4\u63a5\u8d4b\u503c\u7684\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><p>\u76f4\u63a5\u8d4b\u503c\u7684\u65b9\u6cd5\u662f\u6700\u76f4\u63a5\u6700\u7b80\u5355\u7684\u65b9\u6cd5\u3002\u4f60\u53ea\u9700\u8981\u5c06\u5143\u7d20\u7528\u65b9\u62ec\u53f7\u62ec\u8d77\u6765\uff0c\u5e76\u7528\u9017\u53f7\u5206\u9694\u5f00\u6765\u8d4b\u503c\u7ed9\u53d8\u91cf\u5373\u53ef\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">list1 = [1, 2, 3, 4, 5]<\/p>\n<p>list2 = [&#39;a&#39;, &#39;b&#39;, &#39;c&#39;, &#39;d&#39;, &#39;e&#39;]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u8be6\u7ec6\u63a2\u8ba8\u5176\u4ed6\u51e0\u79cd\u521b\u5efa\u5217\u8868\u7684\u65b9\u6cd5\u4ee5\u53ca\u5982\u4f55\u64cd\u4f5c\u548c\u5e94\u7528\u5b83\u4eec\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u76f4\u63a5\u8d4b\u503c<\/h3>\n<\/p>\n<p><p>\u76f4\u63a5\u8d4b\u503c\u662f\u521b\u5efa\u5217\u8868\u6700\u7b80\u5355\u7684\u65b9\u6cd5\u3002\u4f60\u53ea\u9700\u8981\u5c06\u5143\u7d20\u7528\u65b9\u62ec\u53f7\u62ec\u8d77\u6765\uff0c\u5e76\u7528\u9017\u53f7\u5206\u9694\u5f00\u6765\u8d4b\u503c\u7ed9\u53d8\u91cf\u5373\u53ef\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">list1 = [1, 2, 3, 4, 5]<\/p>\n<p>list2 = [&#39;a&#39;, &#39;b&#39;, &#39;c&#39;, &#39;d&#39;, &#39;e&#39;]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u79cd\u65b9\u6cd5\u9002\u7528\u4e8e\u5df2\u7ecf\u660e\u786e\u77e5\u9053\u5217\u8868\u4e2d\u5143\u7d20\u7684\u60c5\u51b5\uff0c\u53ef\u4ee5\u5feb\u901f\u521b\u5efa\u5305\u542b\u7279\u5b9a\u5143\u7d20\u7684\u5217\u8868\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u4f7f\u7528\u5217\u8868\u63a8\u5bfc\u5f0f<\/h3>\n<\/p>\n<p><p>\u5217\u8868\u63a8\u5bfc\u5f0f\u662fPython\u4e2d\u7684\u4e00\u79cd\u7b80\u6d01\u7684\u8bed\u6cd5\uff0c\u7528\u4e8e\u4ece\u4e00\u4e2a\u53ef\u8fed\u4ee3\u5bf9\u8c61\u751f\u6210\u4e00\u4e2a\u65b0\u7684\u5217\u8868\u3002\u901a\u8fc7\u5217\u8868\u63a8\u5bfc\u5f0f\uff0c\u53ef\u4ee5\u6839\u636e\u4e00\u5b9a\u7684\u89c4\u5219\u521b\u5efa\u5217\u8868\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">list1 = [x for x in range(1, 6)]<\/p>\n<p>list2 = [chr(97 + i) for i in range(5)]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>list1<\/code> \u4f7f\u7528 <code>range<\/code> \u51fd\u6570\u751f\u6210\u4e86\u4ece1\u52305\u7684\u6570\u5b57\uff0c\u800c <code>list2<\/code> \u4f7f\u7528 <code>chr<\/code> \u51fd\u6570\u5c06\u6570\u5b57\u8f6c\u6362\u4e3a\u5bf9\u5e94\u7684\u5b57\u6bcd\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u4f7f\u7528\u5185\u7f6e\u51fd\u6570<\/h3>\n<\/p>\n<p><p>Python\u63d0\u4f9b\u4e86\u591a\u79cd\u5185\u7f6e\u51fd\u6570\u6765\u521b\u5efa\u548c\u64cd\u4f5c\u5217\u8868\u3002\u4f8b\u5982\uff0c\u4f7f\u7528 <code>list<\/code> \u51fd\u6570\u53ef\u4ee5\u5c06\u4efb\u4f55\u53ef\u8fed\u4ee3\u5bf9\u8c61\u8f6c\u6362\u4e3a\u5217\u8868\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">list1 = list(range(1, 6))<\/p>\n<p>list2 = list(&#39;abcde&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>list1<\/code> \u4f7f\u7528 <code>range<\/code> \u51fd\u6570\u751f\u6210\u4e86\u4ece1\u52305\u7684\u6570\u5b57\uff0c\u5e76\u5c06\u5176\u8f6c\u6362\u4e3a\u5217\u8868\uff0c\u800c <code>list2<\/code> \u76f4\u63a5\u5c06\u5b57\u7b26\u4e32 <code>abcde<\/code> \u8f6c\u6362\u4e3a\u5305\u542b\u6bcf\u4e2a\u5b57\u7b26\u7684\u5217\u8868\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u4ece\u5176\u4ed6\u6570\u636e\u7ed3\u6784\u8f6c\u6362<\/h3>\n<\/p>\n<p><p>\u6709\u65f6\u5019\uff0c\u6211\u4eec\u53ef\u80fd\u9700\u8981\u4ece\u5176\u4ed6\u6570\u636e\u7ed3\u6784\uff08\u5982\u5143\u7ec4\u3001\u96c6\u5408\u3001\u5b57\u5178\u7b49\uff09\u8f6c\u6362\u6210\u5217\u8868\u3002Python\u63d0\u4f9b\u4e86\u65b9\u4fbf\u7684\u65b9\u6cd5\u6765\u5b9e\u73b0\u8fd9\u4e9b\u64cd\u4f5c\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">tuple1 = (1, 2, 3, 4, 5)<\/p>\n<p>list1 = list(tuple1)<\/p>\n<p>set1 = {&#39;a&#39;, &#39;b&#39;, &#39;c&#39;, &#39;d&#39;, &#39;e&#39;}<\/p>\n<p>list2 = list(set1)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>tuple1<\/code> \u662f\u4e00\u4e2a\u5143\u7ec4\uff0c\u901a\u8fc7 <code>list<\/code> \u51fd\u6570\u5c06\u5176\u8f6c\u6362\u4e3a\u5217\u8868 <code>list1<\/code>\u3002\u540c\u6837\uff0c<code>set1<\/code> \u662f\u4e00\u4e2a\u96c6\u5408\uff0c\u901a\u8fc7 <code>list<\/code> \u51fd\u6570\u5c06\u5176\u8f6c\u6362\u4e3a\u5217\u8868 <code>list2<\/code>\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001\u4f7f\u7528 <code>append<\/code> \u548c <code>extend<\/code> \u65b9\u6cd5<\/h3>\n<\/p>\n<p><p>\u6709\u65f6\u5019\uff0c\u6211\u4eec\u9700\u8981\u4ece\u7a7a\u5217\u8868\u5f00\u59cb\uff0c\u7136\u540e\u9010\u6b65\u6dfb\u52a0\u5143\u7d20\u3002\u8fd9\u65f6\u5019\u53ef\u4ee5\u4f7f\u7528 <code>append<\/code> \u548c <code>extend<\/code> \u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">list1 = []<\/p>\n<p>for i in range(1, 6):<\/p>\n<p>    list1.append(i)<\/p>\n<p>list2 = []<\/p>\n<p>list2.extend([&#39;a&#39;, &#39;b&#39;, &#39;c&#39;, &#39;d&#39;, &#39;e&#39;])<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>list1<\/code> \u4f7f\u7528 <code>append<\/code> \u65b9\u6cd5\u9010\u4e2a\u6dfb\u52a0\u5143\u7d20\uff0c\u800c <code>list2<\/code> \u4f7f\u7528 <code>extend<\/code> \u65b9\u6cd5\u4e00\u6b21\u6027\u6dfb\u52a0\u591a\u4e2a\u5143\u7d20\u3002<\/p>\n<\/p>\n<p><h3>\u516d\u3001\u521b\u5efa\u4e8c\u7ef4\u5217\u8868<\/h3>\n<\/p>\n<p><p>\u4e8c\u7ef4\u5217\u8868\u662f\u5217\u8868\u7684\u5217\u8868\uff0c\u53ef\u4ee5\u7528\u6765\u8868\u793a\u77e9\u9635\u6216\u8868\u683c\u6570\u636e\u3002\u521b\u5efa\u4e8c\u7ef4\u5217\u8868\u7684\u65b9\u6cd5\u4e0e\u521b\u5efa\u666e\u901a\u5217\u8868\u7c7b\u4f3c\uff0c\u53ea\u662f\u5143\u7d20\u672c\u8eab\u4e5f\u662f\u5217\u8868\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">list1 = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]<\/p>\n<p>list2 = [[&#39;a&#39;, &#39;b&#39;, &#39;c&#39;], [&#39;d&#39;, &#39;e&#39;, &#39;f&#39;], [&#39;g&#39;, &#39;h&#39;, &#39;i&#39;]]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>list1<\/code> \u548c <code>list2<\/code> \u90fd\u662f\u4e8c\u7ef4\u5217\u8868\uff0c\u6bcf\u4e2a\u5143\u7d20\u4e5f\u662f\u4e00\u4e2a\u5217\u8868\u3002<\/p>\n<\/p>\n<p><h3>\u4e03\u3001\u4f7f\u7528 <code>numpy<\/code> \u5e93<\/h3>\n<\/p>\n<p><p>\u5bf9\u4e8e\u9700\u8981\u8fdb\u884c\u5927\u91cf\u6570\u503c\u8ba1\u7b97\u7684\u60c5\u51b5\uff0c\u53ef\u4ee5\u4f7f\u7528 <code>numpy<\/code> \u5e93\u6765\u521b\u5efa\u548c\u64cd\u4f5c\u5217\u8868\uff08\u6570\u7ec4\uff09\u3002<code>numpy<\/code> \u63d0\u4f9b\u4e86\u9ad8\u6548\u7684\u591a\u7ef4\u6570\u7ec4\u5bf9\u8c61\u548c\u4e30\u5bcc\u7684\u51fd\u6570\u5e93\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<p>list1 = np.arange(1, 6)<\/p>\n<p>list2 = np.array([&#39;a&#39;, &#39;b&#39;, &#39;c&#39;, &#39;d&#39;, &#39;e&#39;])<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>list1<\/code> \u4f7f\u7528 <code>np.arange<\/code> \u51fd\u6570\u751f\u6210\u4e86\u4ece1\u52305\u7684\u6570\u5b57\uff0c\u800c <code>list2<\/code> \u4f7f\u7528 <code>np.array<\/code> \u51fd\u6570\u751f\u6210\u4e86\u5305\u542b\u5b57\u6bcd\u7684\u6570\u7ec4\u3002<\/p>\n<\/p>\n<p><h3>\u516b\u3001\u4f7f\u7528 <code>itertools<\/code> \u5e93<\/h3>\n<\/p>\n<p><p><code>itertools<\/code> \u5e93\u63d0\u4f9b\u4e86\u591a\u79cd\u8fed\u4ee3\u5668\u751f\u6210\u51fd\u6570\uff0c\u53ef\u4ee5\u7528\u6765\u521b\u5efa\u590d\u6742\u7684\u5217\u8868\u3002\u4f8b\u5982\uff0c\u4f7f\u7528 <code>itertools.product<\/code> \u53ef\u4ee5\u751f\u6210\u7b1b\u5361\u5c14\u79ef\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import itertools<\/p>\n<p>list1 = list(itertools.product([1, 2, 3], repeat=2))<\/p>\n<p>list2 = list(itertools.combinations(&#39;abcde&#39;, 2))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>list1<\/code> \u4f7f\u7528 <code>itertools.product<\/code> \u751f\u6210\u4e86 <code>[1, 2, 3]<\/code> \u7684\u7b1b\u5361\u5c14\u79ef\uff0c\u800c <code>list2<\/code> \u4f7f\u7528 <code>itertools.combinations<\/code> \u751f\u6210\u4e86 <code>abcde<\/code> \u4e2d\u6240\u6709\u957f\u5ea6\u4e3a2\u7684\u7ec4\u5408\u3002<\/p>\n<\/p>\n<p><h3>\u4e5d\u3001\u4f7f\u7528 <code>pandas<\/code> \u5e93<\/h3>\n<\/p>\n<p><p>\u5bf9\u4e8e\u6570\u636e\u5206\u6790\u4efb\u52a1\uff0c<code>pandas<\/code> \u5e93\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u6570\u636e\u7ed3\u6784 <code>DataFrame<\/code> \u548c <code>Series<\/code>\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u521b\u5efa\u548c\u64cd\u4f5c\u5217\u8868\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<p>list1 = pd.Series([1, 2, 3, 4, 5])<\/p>\n<p>list2 = pd.DataFrame({&#39;col1&#39;: [&#39;a&#39;, &#39;b&#39;, &#39;c&#39;, &#39;d&#39;, &#39;e&#39;]})<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>list1<\/code> \u662f\u4e00\u4e2a <code>Series<\/code> \u5bf9\u8c61\uff0c<code>list2<\/code> \u662f\u4e00\u4e2a <code>DataFrame<\/code> \u5bf9\u8c61\u3002<\/p>\n<\/p>\n<p><h3>\u5341\u3001\u4f7f\u7528 <code>random<\/code> \u5e93<\/h3>\n<\/p>\n<p><p>\u6709\u65f6\u5019\uff0c\u6211\u4eec\u9700\u8981\u751f\u6210\u968f\u673a\u5217\u8868\uff0c\u53ef\u4ee5\u4f7f\u7528 <code>random<\/code> \u5e93\u6765\u5b9e\u73b0\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import random<\/p>\n<p>list1 = [random.randint(1, 100) for _ in range(5)]<\/p>\n<p>list2 = [random.choice(&#39;abcdefghijklmnopqrstuvwxyz&#39;) for _ in range(5)]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>list1<\/code> \u751f\u6210\u4e86\u5305\u542b5\u4e2a1\u5230100\u4e4b\u95f4\u7684\u968f\u673a\u6574\u6570\u7684\u5217\u8868\uff0c\u800c <code>list2<\/code> \u751f\u6210\u4e86\u5305\u542b5\u4e2a\u968f\u673a\u5b57\u6bcd\u7684\u5217\u8868\u3002<\/p>\n<\/p>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u51e0\u79cd\u65b9\u6cd5\uff0c\u4f60\u53ef\u4ee5\u6839\u636e\u5177\u4f53\u9700\u6c42\u521b\u5efa\u548c\u64cd\u4f5c\u4e0d\u540c\u7c7b\u578b\u7684\u5217\u8868\u3002\u7406\u89e3\u5e76\u638c\u63e1\u8fd9\u4e9b\u65b9\u6cd5\uff0c\u4e0d\u4ec5\u80fd\u591f\u63d0\u9ad8\u7f16\u7a0b\u6548\u7387\uff0c\u8fd8\u80fd\u66f4\u7075\u6d3b\u5730\u89e3\u51b3\u5b9e\u9645\u95ee\u9898\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u521b\u5efa\u4e24\u4e2a\u4e0d\u540c\u7c7b\u578b\u7684\u5217\u8868\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u60a8\u53ef\u4ee5\u6839\u636e\u9700\u8981\u521b\u5efa\u4e0d\u540c\u7c7b\u578b\u7684\u5217\u8868\u3002\u4f8b\u5982\uff0c\u4e00\u4e2a\u5217\u8868\u53ef\u4ee5\u5305\u542b\u6574\u6570\uff0c\u53e6\u4e00\u4e2a\u5217\u8868\u53ef\u4ee5\u5305\u542b\u5b57\u7b26\u4e32\u3002\u53ef\u4ee5\u4f7f\u7528\u65b9\u62ec\u53f7\u6765\u5b9a\u4e49\u5217\u8868\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre><code class=\"language-python\">list1 = [1, 2, 3, 4, 5]  # \u6574\u6570\u5217\u8868\nlist2 = [&#39;apple&#39;, &#39;banana&#39;, &#39;cherry&#39;]  # \u5b57\u7b26\u4e32\u5217\u8868\n<\/code><\/pre>\n<p>\u8fd9\u6837\uff0c\u60a8\u5c31\u53ef\u4ee5\u8f7b\u677e\u5730\u521b\u5efa\u5e76\u4f7f\u7528\u4e24\u4e2a\u4e0d\u540c\u7c7b\u578b\u7684\u5217\u8868\u3002<\/p>\n<p><strong>\u5728Python\u4e2d\u5982\u4f55\u5bf9\u4e24\u4e2a\u5217\u8868\u8fdb\u884c\u64cd\u4f5c\uff1f<\/strong><br \/>\u60a8\u53ef\u4ee5\u5bf9\u591a\u4e2a\u5217\u8868\u8fdb\u884c\u591a\u79cd\u64cd\u4f5c\uff0c\u4f8b\u5982\u8fde\u63a5\u3001\u5207\u7247\u3001\u904d\u5386\u7b49\u3002\u4f7f\u7528<code>+<\/code>\u8fd0\u7b97\u7b26\u53ef\u4ee5\u8fde\u63a5\u4e24\u4e2a\u5217\u8868\uff1a<\/p>\n<pre><code class=\"language-python\">combined_list = list1 + list2\n<\/code><\/pre>\n<p>\u6b64\u5916\uff0c\u53ef\u4ee5\u4f7f\u7528<code>for<\/code>\u5faa\u73af\u904d\u5386\u4e24\u4e2a\u5217\u8868\u3002\u8fd9\u6837\u53ef\u4ee5\u540c\u65f6\u8bbf\u95ee\u4e24\u4e2a\u5217\u8868\u7684\u5143\u7d20\uff0c\u8fdb\u884c\u6bd4\u8f83\u6216\u5176\u4ed6\u64cd\u4f5c\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728Python\u4e2d\u68c0\u67e5\u4e24\u4e2a\u5217\u8868\u662f\u5426\u76f8\u7b49\uff1f<\/strong><br \/>\u8981\u5224\u65ad\u4e24\u4e2a\u5217\u8868\u662f\u5426\u76f8\u7b49\uff0c\u53ef\u4ee5\u4f7f\u7528<code>==<\/code>\u8fd0\u7b97\u7b26\u3002\u5b83\u4f1a\u6bd4\u8f83\u4e24\u4e2a\u5217\u8868\u4e2d\u7684\u6bcf\u4e2a\u5143\u7d20\u662f\u5426\u76f8\u540c\uff0c\u987a\u5e8f\u4e5f\u5fc5\u987b\u4e00\u81f4\u3002\u4f8b\u5982\uff1a<\/p>\n<pre><code class=\"language-python\">are_equal = list1 == list2\n<\/code><\/pre>\n<p>\u8fd9\u4e2a\u8868\u8fbe\u5f0f\u4f1a\u8fd4\u56de<code>True<\/code>\u6216<code>False<\/code>\uff0c\u6839\u636e\u4e24\u4e2a\u5217\u8868\u7684\u5185\u5bb9\u548c\u987a\u5e8f\u662f\u5426\u76f8\u540c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python\u4e2d\uff0c\u5efa\u7acb\u4e24\u4e2a\u5217\u8868\u53ef\u4ee5\u901a\u8fc7\u7b80\u5355\u7684\u8d4b\u503c\u64cd\u4f5c\u3001\u5217\u8868\u63a8\u5bfc\u5f0f\u4ee5\u53ca\u4f7f\u7528\u5185\u7f6e\u51fd\u6570\u7b49\u65b9\u5f0f\u5b9e\u73b0\u3002 \u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u65b9 [&hellip;]","protected":false},"author":3,"featured_media":1065872,"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\/1065864"}],"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=1065864"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1065864\/revisions"}],"predecessor-version":[{"id":1065876,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1065864\/revisions\/1065876"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1065872"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1065864"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1065864"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1065864"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}