{"id":1182261,"date":"2025-01-15T19:01:10","date_gmt":"2025-01-15T11:01:10","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1182261.html"},"modified":"2025-01-15T19:01:13","modified_gmt":"2025-01-15T11:01:13","slug":"python%e5%a6%82%e4%bd%95%e5%88%9b%e5%bb%ba%e5%a4%9a%e4%b8%aa%e5%ad%97%e5%85%b8","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1182261.html","title":{"rendered":"python\u5982\u4f55\u521b\u5efa\u591a\u4e2a\u5b57\u5178"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25130328\/75d1b36b-6e71-466d-afa5-05fee2b691b4.webp\" alt=\"python\u5982\u4f55\u521b\u5efa\u591a\u4e2a\u5b57\u5178\" \/><\/p>\n<p><p> \u5728Python\u4e2d\u521b\u5efa\u591a\u4e2a\u5b57\u5178\u6709\u591a\u79cd\u65b9\u6cd5\uff0c<strong>\u53ef\u4ee5\u901a\u8fc7\u624b\u52a8\u521b\u5efa\u591a\u4e2a\u5b57\u5178\u3001\u4f7f\u7528\u5217\u8868\u6216\u5143\u7ec4\u5b58\u50a8\u591a\u4e2a\u5b57\u5178\u3001\u4f7f\u7528\u5b57\u5178\u5d4c\u5957\u7b49\u65b9\u5f0f\u8fdb\u884c\u521b\u5efa<\/strong>\u3002\u4e3a\u4e86\u65b9\u4fbf\u7ba1\u7406\u548c\u64cd\u4f5c\uff0c\u6211\u4eec\u53ef\u4ee5\u9009\u62e9\u9002\u5408\u7684\u65b9\u5f0f\u6765\u521b\u5efa\u548c\u5b58\u50a8\u591a\u4e2a\u5b57\u5178\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u8fd9\u4e9b\u65b9\u6cd5\uff0c\u5e76\u5c55\u793a\u5982\u4f55\u4f7f\u7528\u5b83\u4eec\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u624b\u52a8\u521b\u5efa\u591a\u4e2a\u5b57\u5178<\/h3>\n<\/p>\n<p><p>\u624b\u52a8\u521b\u5efa\u591a\u4e2a\u5b57\u5178\u662f\u6700\u76f4\u63a5\u7684\u65b9\u6cd5\u3002\u6211\u4eec\u53ef\u4ee5\u4e3a\u6bcf\u4e2a\u5b57\u5178\u8d4b\u4e88\u4e00\u4e2a\u552f\u4e00\u7684\u53d8\u91cf\u540d\uff0c\u7136\u540e\u5206\u522b\u521d\u59cb\u5316\u8fd9\u4e9b\u5b57\u5178\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u624b\u52a8\u521b\u5efa\u591a\u4e2a\u5b57\u5178<\/p>\n<p>dict1 = {&#39;name&#39;: &#39;Alice&#39;, &#39;age&#39;: 25}<\/p>\n<p>dict2 = {&#39;name&#39;: &#39;Bob&#39;, &#39;age&#39;: 30}<\/p>\n<p>dict3 = {&#39;name&#39;: &#39;Charlie&#39;, &#39;age&#39;: 35}<\/p>\n<h2><strong>\u6253\u5370\u5b57\u5178<\/strong><\/h2>\n<p>print(dict1)<\/p>\n<p>print(dict2)<\/p>\n<p>print(dict3)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u79cd\u65b9\u6cd5\u9002\u7528\u4e8e\u5b57\u5178\u6570\u91cf\u8f83\u5c11\u7684\u60c5\u51b5\u3002\u5982\u679c\u9700\u8981\u521b\u5efa\u5927\u91cf\u7684\u5b57\u5178\uff0c\u8fd9\u79cd\u65b9\u6cd5\u4f1a\u663e\u5f97\u7e41\u7410\u4e14\u4e0d\u6613\u7ba1\u7406\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u4f7f\u7528\u5217\u8868\u5b58\u50a8\u591a\u4e2a\u5b57\u5178<\/h3>\n<\/p>\n<p><p>\u4f7f\u7528\u5217\u8868\u5b58\u50a8\u591a\u4e2a\u5b57\u5178\u662f\u4e00\u79cd\u5e38\u89c1\u7684\u65b9\u6cd5\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u8fdb\u884c\u904d\u5386\u548c\u6279\u91cf\u64cd\u4f5c\u3002\u6211\u4eec\u53ef\u4ee5\u5c06\u6bcf\u4e2a\u5b57\u5178\u4f5c\u4e3a\u5217\u8868\u7684\u4e00\u4e2a\u5143\u7d20\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u4f7f\u7528\u5217\u8868\u5b58\u50a8\u591a\u4e2a\u5b57\u5178<\/p>\n<p>dicts = [<\/p>\n<p>    {&#39;name&#39;: &#39;Alice&#39;, &#39;age&#39;: 25},<\/p>\n<p>    {&#39;name&#39;: &#39;Bob&#39;, &#39;age&#39;: 30},<\/p>\n<p>    {&#39;name&#39;: &#39;Charlie&#39;, &#39;age&#39;: 35}<\/p>\n<p>]<\/p>\n<h2><strong>\u904d\u5386\u5e76\u6253\u5370\u6bcf\u4e2a\u5b57\u5178<\/strong><\/h2>\n<p>for d in dicts:<\/p>\n<p>    print(d)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u79cd\u65b9\u6cd5\u9002\u7528\u4e8e\u9700\u8981\u5bf9\u591a\u4e2a\u5b57\u5178\u8fdb\u884c\u6279\u91cf\u64cd\u4f5c\u7684\u573a\u666f\uff0c\u4f8b\u5982\u904d\u5386\u3001\u7b5b\u9009\u548c\u4fee\u6539\u7b49\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u4f7f\u7528\u5143\u7ec4\u5b58\u50a8\u591a\u4e2a\u5b57\u5178<\/h3>\n<\/p>\n<p><p>\u7c7b\u4f3c\u4e8e\u5217\u8868\uff0c\u5143\u7ec4\u4e5f\u53ef\u4ee5\u7528\u6765\u5b58\u50a8\u591a\u4e2a\u5b57\u5178\u3002\u4e0d\u540c\u7684\u662f\uff0c\u5143\u7ec4\u662f\u4e0d\u53ef\u53d8\u7684\uff0c\u5982\u679c\u4e0d\u9700\u8981\u5bf9\u5b57\u5178\u96c6\u5408\u8fdb\u884c\u4fee\u6539\uff0c\u53ef\u4ee5\u9009\u62e9\u4f7f\u7528\u5143\u7ec4\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u4f7f\u7528\u5143\u7ec4\u5b58\u50a8\u591a\u4e2a\u5b57\u5178<\/p>\n<p>dicts = (<\/p>\n<p>    {&#39;name&#39;: &#39;Alice&#39;, &#39;age&#39;: 25},<\/p>\n<p>    {&#39;name&#39;: &#39;Bob&#39;, &#39;age&#39;: 30},<\/p>\n<p>    {&#39;name&#39;: &#39;Charlie&#39;, &#39;age&#39;: 35}<\/p>\n<p>)<\/p>\n<h2><strong>\u904d\u5386\u5e76\u6253\u5370\u6bcf\u4e2a\u5b57\u5178<\/strong><\/h2>\n<p>for d in dicts:<\/p>\n<p>    print(d)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u56db\u3001\u4f7f\u7528\u5b57\u5178\u5d4c\u5957<\/h3>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u53ef\u4ee5\u901a\u8fc7\u5b57\u5178\u5d4c\u5957\u6765\u7ba1\u7406\u591a\u4e2a\u5b57\u5178\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e2a\u5b57\u5178\u6765\u5b58\u50a8\u591a\u4e2a\u5b50\u5b57\u5178\uff0c\u5176\u4e2d\u6bcf\u4e2a\u5b50\u5b57\u5178\u7531\u4e00\u4e2a\u552f\u4e00\u7684\u952e\u6765\u6807\u8bc6\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u4f7f\u7528\u5b57\u5178\u5d4c\u5957<\/p>\n<p>dicts = {<\/p>\n<p>    &#39;person1&#39;: {&#39;name&#39;: &#39;Alice&#39;, &#39;age&#39;: 25},<\/p>\n<p>    &#39;person2&#39;: {&#39;name&#39;: &#39;Bob&#39;, &#39;age&#39;: 30},<\/p>\n<p>    &#39;person3&#39;: {&#39;name&#39;: &#39;Charlie&#39;, &#39;age&#39;: 35}<\/p>\n<p>}<\/p>\n<h2><strong>\u8bbf\u95ee\u5e76\u6253\u5370\u6bcf\u4e2a\u5b50\u5b57\u5178<\/strong><\/h2>\n<p>for key, value in dicts.items():<\/p>\n<p>    print(f&#39;{key}: {value}&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u79cd\u65b9\u6cd5\u9002\u7528\u4e8e\u9700\u8981\u901a\u8fc7\u552f\u4e00\u6807\u8bc6\u7b26\u5feb\u901f\u8bbf\u95ee\u67d0\u4e2a\u5b57\u5178\u7684\u60c5\u51b5\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001\u52a8\u6001\u521b\u5efa\u591a\u4e2a\u5b57\u5178<\/h3>\n<\/p>\n<p><p>\u5728\u4e00\u4e9b\u52a8\u6001\u573a\u666f\u4e2d\uff0c\u6211\u4eec\u53ef\u80fd\u9700\u8981\u6839\u636e\u67d0\u4e9b\u6761\u4ef6\u6216\u8f93\u5165\u52a8\u6001\u5730\u521b\u5efa\u591a\u4e2a\u5b57\u5178\u3002\u53ef\u4ee5\u4f7f\u7528\u5faa\u73af\u6216\u63a8\u5bfc\u5f0f\u6765\u5b9e\u73b0\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u52a8\u6001\u521b\u5efa\u591a\u4e2a\u5b57\u5178<\/p>\n<p>dicts = []<\/p>\n<p>for i in range(3):<\/p>\n<p>    dicts.append({&#39;name&#39;: f&#39;Person{i+1}&#39;, &#39;age&#39;: 20 + i})<\/p>\n<h2><strong>\u6253\u5370\u52a8\u6001\u521b\u5efa\u7684\u5b57\u5178<\/strong><\/h2>\n<p>for d in dicts:<\/p>\n<p>    print(d)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u516d\u3001\u7ed3\u5408\u51fd\u6570\u521b\u5efa\u591a\u4e2a\u5b57\u5178<\/h3>\n<\/p>\n<p><p>\u4e3a\u4e86\u66f4\u597d\u5730\u7ec4\u7ec7\u4ee3\u7801\uff0c\u53ef\u4ee5\u4f7f\u7528\u51fd\u6570\u6765\u521b\u5efa\u591a\u4e2a\u5b57\u5178\uff0c\u5e76\u8fd4\u56de\u5305\u542b\u8fd9\u4e9b\u5b57\u5178\u7684\u6570\u636e\u7ed3\u6784\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u5b9a\u4e49\u51fd\u6570\u521b\u5efa\u591a\u4e2a\u5b57\u5178<\/p>\n<p>def create_dicts(n):<\/p>\n<p>    dicts = []<\/p>\n<p>    for i in range(n):<\/p>\n<p>        dicts.append({&#39;name&#39;: f&#39;Person{i+1}&#39;, &#39;age&#39;: 20 + i})<\/p>\n<p>    return dicts<\/p>\n<h2><strong>\u8c03\u7528\u51fd\u6570\u521b\u5efa\u5b57\u5178<\/strong><\/h2>\n<p>dicts = create_dicts(3)<\/p>\n<h2><strong>\u6253\u5370\u51fd\u6570\u521b\u5efa\u7684\u5b57\u5178<\/strong><\/h2>\n<p>for d in dicts:<\/p>\n<p>    print(d)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e03\u3001\u4ece\u6587\u4ef6\u6216\u6570\u636e\u5e93\u8bfb\u53d6\u591a\u4e2a\u5b57\u5178<\/h3>\n<\/p>\n<p><p>\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u591a\u4e2a\u5b57\u5178\u7684\u6570\u636e\u6765\u6e90\u53ef\u80fd\u662f\u6587\u4ef6\u6216\u6570\u636e\u5e93\u3002\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u8bfb\u53d6\u6587\u4ef6\u6216\u67e5\u8be2\u6570\u636e\u5e93\u6765\u521b\u5efa\u591a\u4e2a\u5b57\u5178\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import json<\/p>\n<h2><strong>\u4eceJSON\u6587\u4ef6\u8bfb\u53d6\u591a\u4e2a\u5b57\u5178<\/strong><\/h2>\n<p>with open(&#39;data.json&#39;, &#39;r&#39;) as file:<\/p>\n<p>    dicts = json.load(file)<\/p>\n<h2><strong>\u6253\u5370\u8bfb\u53d6\u7684\u5b57\u5178<\/strong><\/h2>\n<p>for d in dicts:<\/p>\n<p>    print(d)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u516b\u3001\u7ed3\u5408\u7c7b\u548c\u5bf9\u8c61\u521b\u5efa\u591a\u4e2a\u5b57\u5178<\/h3>\n<\/p>\n<p><p>\u5728\u9762\u5411\u5bf9\u8c61\u7f16\u7a0b\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u5b9a\u4e49\u7c7b\u6765\u7ba1\u7406\u591a\u4e2a\u5b57\u5178\u3002\u6bcf\u4e2a\u5b57\u5178\u53ef\u4ee5\u4f5c\u4e3a\u4e00\u4e2a\u5bf9\u8c61\u7684\u5c5e\u6027\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u5b9a\u4e49Person\u7c7b<\/p>\n<p>class Person:<\/p>\n<p>    def __init__(self, name, age):<\/p>\n<p>        self.name = name<\/p>\n<p>        self.age = age<\/p>\n<h2><strong>\u521b\u5efa\u591a\u4e2aPerson\u5bf9\u8c61<\/strong><\/h2>\n<p>persons = [<\/p>\n<p>    Person(&#39;Alice&#39;, 25),<\/p>\n<p>    Person(&#39;Bob&#39;, 30),<\/p>\n<p>    Person(&#39;Charlie&#39;, 35)<\/p>\n<p>]<\/p>\n<h2><strong>\u6253\u5370Person\u5bf9\u8c61\u7684\u5c5e\u6027<\/strong><\/h2>\n<p>for person in persons:<\/p>\n<p>    print(f&#39;Name: {person.name}, Age: {person.age}&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e5d\u3001\u4f7f\u7528\u5b57\u5178\u63a8\u5bfc\u5f0f\u521b\u5efa\u591a\u4e2a\u5b57\u5178<\/h3>\n<\/p>\n<p><p>\u5b57\u5178\u63a8\u5bfc\u5f0f\u662f\u4e00\u79cd\u7b80\u6d01\u7684\u521b\u5efa\u5b57\u5178\u7684\u65b9\u6cd5\uff0c\u53ef\u4ee5\u7528\u6765\u521b\u5efa\u591a\u4e2a\u5b57\u5178\u5e76\u5b58\u50a8\u5728\u4e00\u4e2a\u5217\u8868\u6216\u5176\u4ed6\u6570\u636e\u7ed3\u6784\u4e2d\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u4f7f\u7528\u5b57\u5178\u63a8\u5bfc\u5f0f\u521b\u5efa\u591a\u4e2a\u5b57\u5178<\/p>\n<p>dicts = [{&#39;name&#39;: f&#39;Person{i+1}&#39;, &#39;age&#39;: 20 + i} for i in range(3)]<\/p>\n<h2><strong>\u6253\u5370\u5b57\u5178\u63a8\u5bfc\u5f0f\u521b\u5efa\u7684\u5b57\u5178<\/strong><\/h2>\n<p>for d in dicts:<\/p>\n<p>    print(d)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u5341\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u5728Python\u4e2d\u521b\u5efa\u591a\u4e2a\u5b57\u5178\u6709\u591a\u79cd\u65b9\u6cd5\uff0c\u5305\u62ec<strong>\u624b\u52a8\u521b\u5efa\u3001\u4f7f\u7528\u5217\u8868\u6216\u5143\u7ec4\u5b58\u50a8\u3001\u5b57\u5178\u5d4c\u5957\u3001\u52a8\u6001\u521b\u5efa\u3001\u7ed3\u5408\u51fd\u6570\u3001\u4ece\u6587\u4ef6\u6216\u6570\u636e\u5e93\u8bfb\u53d6\u3001\u7ed3\u5408\u7c7b\u548c\u5bf9\u8c61\u3001\u4f7f\u7528\u5b57\u5178\u63a8\u5bfc\u5f0f<\/strong>\u7b49\u3002\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\u53ef\u4ee5\u63d0\u9ad8\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u548c\u53ef\u7ef4\u62a4\u6027\u3002\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u6839\u636e\u5177\u4f53\u9700\u6c42\u9009\u62e9\u6700\u9002\u5408\u7684\u65b9\u6cd5\u6765\u521b\u5efa\u548c\u7ba1\u7406\u591a\u4e2a\u5b57\u5178\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u521b\u5efa\u4e00\u4e2a\u5b57\u5178\u7684\u5217\u8868\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u5217\u8868\u63a8\u5bfc\u5f0f\u8f7b\u677e\u521b\u5efa\u4e00\u4e2a\u5b57\u5178\u7684\u5217\u8868\u3002\u4f8b\u5982\uff0c\u5047\u8bbe\u60a8\u9700\u8981\u521b\u5efa\u4e09\u4e2a\u5b57\u5178\uff0c\u6bcf\u4e2a\u5b57\u5178\u5305\u542b\u4e00\u4e9b\u76f8\u540c\u7684\u952e\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\uff1a  <\/p>\n<pre><code class=\"language-python\">dict_list = [{ &quot;name&quot;: f&quot;item{i}&quot;, &quot;value&quot;: i } for i in range(3)]\n<\/code><\/pre>\n<p>\u8fd9\u6837\u4f1a\u751f\u6210\u4e00\u4e2a\u5305\u542b\u4e09\u4e2a\u5b57\u5178\u7684\u5217\u8868\uff0c\u8f93\u51fa\u7ed3\u679c\u4e3a\uff1a[{&#39;name&#39;: &#39;item0&#39;, &#39;value&#39;: 0}, {&#39;name&#39;: &#39;item1&#39;, &#39;value&#39;: 1}, {&#39;name&#39;: &#39;item2&#39;, &#39;value&#39;: 2}]\u3002<\/p>\n<p><strong>\u5728Python\u4e2d\u5982\u4f55\u5408\u5e76\u591a\u4e2a\u5b57\u5178\uff1f<\/strong><br \/>\u5408\u5e76\u591a\u4e2a\u5b57\u5178\u53ef\u4ee5\u4f7f\u7528<code>update()<\/code>\u65b9\u6cd5\u6216<code>{&lt;strong&gt;d1, &lt;\/strong&gt;d2}<\/code>\u7684\u65b9\u5f0f\u6765\u5b9e\u73b0\u3002\u4f7f\u7528<code>update()<\/code>\u65b9\u6cd5\uff0c\u60a8\u53ef\u4ee5\u9010\u4e2a\u5c06\u5b57\u5178\u7684\u952e\u503c\u5bf9\u6dfb\u52a0\u5230\u4e00\u4e2a\u76ee\u6807\u5b57\u5178\u4e2d\u3002\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a  <\/p>\n<pre><code class=\"language-python\">dict1 = {&#39;a&#39;: 1, &#39;b&#39;: 2}\ndict2 = {&#39;b&#39;: 3, &#39;c&#39;: 4}\ndict1.update(dict2)\n<\/code><\/pre>\n<p>\u5408\u5e76\u540e\u7684<code>dict1<\/code>\u5c06\u4f1a\u662f<code>{&#39;a&#39;: 1, &#39;b&#39;: 3, &#39;c&#39;: 4}<\/code>\u3002\u800c\u4f7f\u7528\u89e3\u5305\u7684\u65b9\u5f0f\u5219\u53ef\u4ee5\u901a\u8fc7<code>{&lt;strong&gt;dict1, &lt;\/strong&gt;dict2}<\/code>\u6765\u5408\u5e76\uff0c\u9002\u7528\u4e8e\u521b\u5efa\u65b0\u7684\u5b57\u5178\u3002<\/p>\n<p><strong>\u5982\u4f55\u4f7f\u7528\u5faa\u73af\u521b\u5efa\u591a\u4e2a\u5b57\u5178\u5e76\u8d4b\u503c\uff1f<\/strong><br \/>\u53ef\u4ee5\u4f7f\u7528\u5faa\u73af\u6765\u521b\u5efa\u591a\u4e2a\u5b57\u5178\u5e76\u4e3a\u5176\u8d4b\u503c\u3002\u4e3e\u4e2a\u4f8b\u5b50\uff0c\u5047\u8bbe\u60a8\u60f3\u8981\u6839\u636e\u67d0\u4e9b\u6570\u636e\u521b\u5efa\u591a\u4e2a\u5b57\u5178\uff0c\u53ef\u4ee5\u50cf\u8fd9\u6837\uff1a  <\/p>\n<pre><code class=\"language-python\">data = [&#39;apple&#39;, &#39;banana&#39;, &#39;cherry&#39;]\ndicts = []\nfor item in data:\n    dicts.append({&#39;fruit&#39;: item})\n<\/code><\/pre>\n<p>\u901a\u8fc7\u8fd9\u6bb5\u4ee3\u7801\uff0c\u60a8\u4f1a\u5f97\u5230\u4e00\u4e2a\u5305\u542b\u4e09\u4e2a\u5b57\u5178\u7684\u5217\u8868\uff0c\u6bcf\u4e2a\u5b57\u5178\u90fd\u6709\u4e00\u4e2a&#39;fruit&#39;\u952e\u548c\u76f8\u5e94\u7684\u6c34\u679c\u540d\u79f0\u3002\u7ed3\u679c\u4e3a\uff1a[{&#39;fruit&#39;: &#39;apple&#39;}, {&#39;fruit&#39;: &#39;banana&#39;}, {&#39;fruit&#39;: &#39;cherry&#39;}]\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python\u4e2d\u521b\u5efa\u591a\u4e2a\u5b57\u5178\u6709\u591a\u79cd\u65b9\u6cd5\uff0c\u53ef\u4ee5\u901a\u8fc7\u624b\u52a8\u521b\u5efa\u591a\u4e2a\u5b57\u5178\u3001\u4f7f\u7528\u5217\u8868\u6216\u5143\u7ec4\u5b58\u50a8\u591a\u4e2a\u5b57\u5178\u3001\u4f7f\u7528\u5b57\u5178\u5d4c\u5957\u7b49\u65b9 [&hellip;]","protected":false},"author":3,"featured_media":1182269,"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\/1182261"}],"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=1182261"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1182261\/revisions"}],"predecessor-version":[{"id":1182273,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1182261\/revisions\/1182273"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1182269"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1182261"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1182261"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1182261"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}