{"id":1097566,"date":"2025-01-08T15:13:06","date_gmt":"2025-01-08T07:13:06","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1097566.html"},"modified":"2025-01-08T15:13:09","modified_gmt":"2025-01-08T07:13:09","slug":"python%e5%a6%82%e4%bd%95%e8%8e%b7%e5%8f%96%e5%ad%97%e5%85%b8%e4%b8%ad%e7%9a%84%e9%94%ae-2","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1097566.html","title":{"rendered":"python\u5982\u4f55\u83b7\u53d6\u5b57\u5178\u4e2d\u7684\u952e"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24212255\/fd19791f-de7a-4222-bdb9-2ffa5367167a.webp\" alt=\"python\u5982\u4f55\u83b7\u53d6\u5b57\u5178\u4e2d\u7684\u952e\" \/><\/p>\n<p><p> <strong>\u5728Python\u4e2d\uff0c\u83b7\u53d6\u5b57\u5178\u4e2d\u7684\u952e\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5\uff1a\u4f7f\u7528dict.keys()\u65b9\u6cd5\u3001\u4f7f\u7528for\u5faa\u73af\u904d\u5386\u3001\u4f7f\u7528\u5217\u8868\u63a8\u5bfc\u5f0f\u3002<\/strong>\u5728\u8fd9\u4e9b\u65b9\u6cd5\u4e2d\uff0cdict.keys()\u65b9\u6cd5\u662f\u6700\u76f4\u63a5\u548c\u5e38\u7528\u7684\u65b9\u6cd5\uff0c\u5b83\u8fd4\u56de\u4e00\u4e2a\u89c6\u56fe\u5bf9\u8c61\uff0c\u8be5\u5bf9\u8c61\u663e\u793a\u5b57\u5178\u4e2d\u6240\u6709\u7684\u952e\u3002\u4e0b\u9762\u8be6\u7ec6\u4ecb\u7ecd\u5176\u4e2d\u4e00\u79cd\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><p>\u4f7f\u7528dict.keys()\u65b9\u6cd5\u662f\u83b7\u53d6\u5b57\u5178\u4e2d\u952e\u7684\u6700\u7b80\u5355\u65b9\u6cd5\u3002\u8fd9\u4e2a\u65b9\u6cd5\u4e0d\u9700\u8981\u989d\u5916\u7684\u4ee3\u7801\uff0c\u53ea\u9700\u8c03\u7528\u5b57\u5178\u7684keys()\u65b9\u6cd5\u5373\u53ef\u3002\u8fd9\u4e2a\u65b9\u6cd5\u8fd4\u56de\u4e00\u4e2a\u89c6\u56fe\u5bf9\u8c61\uff0c\u5305\u542b\u5b57\u5178\u4e2d\u7684\u6240\u6709\u952e\u3002\u8fd9\u4e2a\u89c6\u56fe\u5bf9\u8c61\u53ef\u4ee5\u50cf\u5217\u8868\u4e00\u6837\u88ab\u904d\u5386\uff0c\u4f46\u5b83\u5e76\u4e0d\u662f\u4e00\u4e2a\u771f\u6b63\u7684\u5217\u8868\u3002\u5982\u679c\u9700\u8981\u4e00\u4e2a\u771f\u6b63\u7684\u5217\u8868\uff0c\u53ef\u4ee5\u5c06\u8fd9\u4e2a\u89c6\u56fe\u5bf9\u8c61\u8f6c\u6362\u4e3a\u5217\u8868\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u4f7f\u7528dict.keys()\u65b9\u6cd5<\/p>\n<\/p>\n<p><p>\u4f7f\u7528dict.keys()\u65b9\u6cd5\u662f\u6700\u76f4\u63a5\u548c\u5e38\u7528\u7684\u65b9\u6cd5\u3002\u5b83\u8fd4\u56de\u4e00\u4e2a\u89c6\u56fe\u5bf9\u8c61\uff0c\u663e\u793a\u5b57\u5178\u4e2d\u6240\u6709\u7684\u952e\u3002\u89c6\u56fe\u5bf9\u8c61\u53ef\u4ee5\u50cf\u5217\u8868\u4e00\u6837\u88ab\u8fed\u4ee3\uff0c\u4f46\u5b83\u4e0d\u662f\u4e00\u4e2a\u771f\u6b63\u7684\u5217\u8868\u3002\u5982\u679c\u9700\u8981\u4e00\u4e2a\u771f\u6b63\u7684\u5217\u8868\uff0c\u53ef\u4ee5\u5c06\u89c6\u56fe\u5bf9\u8c61\u8f6c\u6362\u4e3a\u5217\u8868\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u521b\u5efa\u4e00\u4e2a\u5b57\u5178<\/p>\n<p>my_dict = {&#39;name&#39;: &#39;Alice&#39;, &#39;age&#39;: 25, &#39;city&#39;: &#39;New York&#39;}<\/p>\n<h2><strong>\u4f7f\u7528dict.keys()\u65b9\u6cd5\u83b7\u53d6\u5b57\u5178\u4e2d\u7684\u952e<\/strong><\/h2>\n<p>keys = my_dict.keys()<\/p>\n<h2><strong>\u6253\u5370\u952e<\/strong><\/h2>\n<p>print(keys)  # \u8f93\u51fa: dict_keys([&#39;name&#39;, &#39;age&#39;, &#39;city&#39;])<\/p>\n<h2><strong>\u5c06\u89c6\u56fe\u5bf9\u8c61\u8f6c\u6362\u4e3a\u5217\u8868<\/strong><\/h2>\n<p>keys_list = list(keys)<\/p>\n<p>print(keys_list)  # \u8f93\u51fa: [&#39;name&#39;, &#39;age&#39;, &#39;city&#39;]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4e8c\u3001\u4f7f\u7528for\u5faa\u73af\u904d\u5386<\/p>\n<\/p>\n<p><p>\u53e6\u4e00\u79cd\u83b7\u53d6\u5b57\u5178\u952e\u7684\u65b9\u6cd5\u662f\u4f7f\u7528for\u5faa\u73af\u904d\u5386\u5b57\u5178\u3002\u904d\u5386\u5b57\u5178\u65f6\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u4f1a\u904d\u5386\u5b57\u5178\u7684\u952e\u3002\u8fd9\u6837\u53ef\u4ee5\u8bbf\u95ee\u6bcf\u4e2a\u952e\uff0c\u5e76\u6839\u636e\u9700\u8981\u5bf9\u5176\u8fdb\u884c\u5904\u7406\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u521b\u5efa\u4e00\u4e2a\u5b57\u5178<\/p>\n<p>my_dict = {&#39;name&#39;: &#39;Alice&#39;, &#39;age&#39;: 25, &#39;city&#39;: &#39;New York&#39;}<\/p>\n<h2><strong>\u4f7f\u7528for\u5faa\u73af\u904d\u5386\u5b57\u5178\u7684\u952e<\/strong><\/h2>\n<p>for key in my_dict:<\/p>\n<p>    print(key)  # \u8f93\u51fa: name, age, city<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4e09\u3001\u4f7f\u7528\u5217\u8868\u63a8\u5bfc\u5f0f<\/p>\n<\/p>\n<p><p>\u5217\u8868\u63a8\u5bfc\u5f0f\u662f\u4e00\u79cd\u7b80\u6d01\u7684\u8bed\u6cd5\uff0c\u7528\u4e8e\u751f\u6210\u5217\u8868\u3002\u53ef\u4ee5\u4f7f\u7528\u5217\u8868\u63a8\u5bfc\u5f0f\u4ece\u5b57\u5178\u4e2d\u63d0\u53d6\u6240\u6709\u952e\uff0c\u5e76\u5c06\u5b83\u4eec\u5b58\u50a8\u5728\u4e00\u4e2a\u5217\u8868\u4e2d\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u521b\u5efa\u4e00\u4e2a\u5b57\u5178<\/p>\n<p>my_dict = {&#39;name&#39;: &#39;Alice&#39;, &#39;age&#39;: 25, &#39;city&#39;: &#39;New York&#39;}<\/p>\n<h2><strong>\u4f7f\u7528\u5217\u8868\u63a8\u5bfc\u5f0f\u83b7\u53d6\u5b57\u5178\u4e2d\u7684\u952e<\/strong><\/h2>\n<p>keys_list = [key for key in my_dict]<\/p>\n<p>print(keys_list)  # \u8f93\u51fa: [&#39;name&#39;, &#39;age&#39;, &#39;city&#39;]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u56db\u3001\u4f7f\u7528dict.items()\u65b9\u6cd5<\/p>\n<\/p>\n<p><p>\u867d\u7136dict.items()\u65b9\u6cd5\u4e3b\u8981\u7528\u4e8e\u83b7\u53d6\u5b57\u5178\u4e2d\u7684\u952e\u503c\u5bf9\uff0c\u4f46\u4e5f\u53ef\u4ee5\u7528\u6765\u83b7\u53d6\u952e\u3002\u901a\u8fc7\u89e3\u5305\u6bcf\u4e2a\u952e\u503c\u5bf9\uff0c\u53ef\u4ee5\u5355\u72ec\u8bbf\u95ee\u952e\uff0c\u5e76\u5c06\u5b83\u4eec\u5b58\u50a8\u5728\u4e00\u4e2a\u5217\u8868\u4e2d\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u521b\u5efa\u4e00\u4e2a\u5b57\u5178<\/p>\n<p>my_dict = {&#39;name&#39;: &#39;Alice&#39;, &#39;age&#39;: 25, &#39;city&#39;: &#39;New York&#39;}<\/p>\n<h2><strong>\u4f7f\u7528dict.items()\u65b9\u6cd5\u83b7\u53d6\u5b57\u5178\u4e2d\u7684\u952e<\/strong><\/h2>\n<p>keys_list = [key for key, value in my_dict.items()]<\/p>\n<p>print(keys_list)  # \u8f93\u51fa: [&#39;name&#39;, &#39;age&#39;, &#39;city&#39;]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4e94\u3001\u4f7f\u7528dict.keys()\u65b9\u6cd5\u4e0eset\u64cd\u4f5c<\/p>\n<\/p>\n<p><p>\u5982\u679c\u9700\u8981\u83b7\u53d6\u591a\u4e2a\u5b57\u5178\u4e2d\u6240\u6709\u552f\u4e00\u7684\u952e\uff0c\u53ef\u4ee5\u4f7f\u7528dict.keys()\u65b9\u6cd5\u4e0eset\u64cd\u4f5c\u7ed3\u5408\u4f7f\u7528\u3002\u901a\u8fc7\u5c06\u6240\u6709\u952e\u5b58\u50a8\u5728\u4e00\u4e2a\u96c6\u5408\u4e2d\uff0c\u53ef\u4ee5\u786e\u4fdd\u952e\u7684\u552f\u4e00\u6027\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \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;city&#39;: &#39;New York&#39;, &#39;age&#39;: 30}<\/p>\n<p>dict3 = {&#39;country&#39;: &#39;USA&#39;, &#39;name&#39;: &#39;Bob&#39;}<\/p>\n<h2><strong>\u4f7f\u7528dict.keys()\u65b9\u6cd5\u4e0eset\u64cd\u4f5c\u83b7\u53d6\u6240\u6709\u552f\u4e00\u7684\u952e<\/strong><\/h2>\n<p>unique_keys = set(dict1.keys()).union(dict2.keys()).union(dict3.keys())<\/p>\n<p>print(unique_keys)  # \u8f93\u51fa: {&#39;name&#39;, &#39;city&#39;, &#39;age&#39;, &#39;country&#39;}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u516d\u3001\u4f7f\u7528\u5b57\u5178\u952e\u7684\u4ea4\u96c6<\/p>\n<\/p>\n<p><p>\u6709\u65f6\u53ef\u80fd\u9700\u8981\u83b7\u53d6\u591a\u4e2a\u5b57\u5178\u4e2d\u5171\u6709\u7684\u952e\u3002\u53ef\u4ee5\u4f7f\u7528\u96c6\u5408\u7684\u4ea4\u96c6\u64cd\u4f5c\u6765\u5b9e\u73b0\u8fd9\u4e00\u70b9\u3002\u901a\u8fc7\u5c06\u6bcf\u4e2a\u5b57\u5178\u7684\u952e\u89c6\u56fe\u5bf9\u8c61\u8f6c\u6362\u4e3a\u96c6\u5408\uff0c\u7136\u540e\u4f7f\u7528\u96c6\u5408\u7684\u4ea4\u96c6\u65b9\u6cd5\uff0c\u53ef\u4ee5\u83b7\u53d6\u5171\u6709\u7684\u952e\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \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;city&#39;: &#39;New York&#39;, &#39;age&#39;: 30}<\/p>\n<p>dict3 = {&#39;country&#39;: &#39;USA&#39;, &#39;age&#39;: 40}<\/p>\n<h2><strong>\u4f7f\u7528\u96c6\u5408\u7684\u4ea4\u96c6\u64cd\u4f5c\u83b7\u53d6\u5171\u6709\u7684\u952e<\/strong><\/h2>\n<p>common_keys = set(dict1.keys()).intersection(dict2.keys()).intersection(dict3.keys())<\/p>\n<p>print(common_keys)  # \u8f93\u51fa: {&#39;age&#39;}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4e03\u3001\u4f7f\u7528\u5b57\u5178\u952e\u7684\u5dee\u96c6<\/p>\n<\/p>\n<p><p>\u5982\u679c\u9700\u8981\u83b7\u53d6\u4e00\u4e2a\u5b57\u5178\u4e2d\u6709\u4f46\u53e6\u4e00\u4e2a\u5b57\u5178\u4e2d\u6ca1\u6709\u7684\u952e\uff0c\u53ef\u4ee5\u4f7f\u7528\u96c6\u5408\u7684\u5dee\u96c6\u64cd\u4f5c\u3002\u901a\u8fc7\u5c06\u6bcf\u4e2a\u5b57\u5178\u7684\u952e\u89c6\u56fe\u5bf9\u8c61\u8f6c\u6362\u4e3a\u96c6\u5408\uff0c\u7136\u540e\u4f7f\u7528\u96c6\u5408\u7684\u5dee\u96c6\u65b9\u6cd5\uff0c\u53ef\u4ee5\u83b7\u53d6\u7279\u5b9a\u7684\u952e\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u521b\u5efa\u4e24\u4e2a\u5b57\u5178<\/p>\n<p>dict1 = {&#39;name&#39;: &#39;Alice&#39;, &#39;age&#39;: 25, &#39;city&#39;: &#39;New York&#39;}<\/p>\n<p>dict2 = {&#39;name&#39;: &#39;Bob&#39;, &#39;country&#39;: &#39;USA&#39;}<\/p>\n<h2><strong>\u4f7f\u7528\u96c6\u5408\u7684\u5dee\u96c6\u64cd\u4f5c\u83b7\u53d6\u7b2c\u4e00\u4e2a\u5b57\u5178\u4e2d\u6709\u4f46\u7b2c\u4e8c\u4e2a\u5b57\u5178\u4e2d\u6ca1\u6709\u7684\u952e<\/strong><\/h2>\n<p>unique_keys = set(dict1.keys()).difference(dict2.keys())<\/p>\n<p>print(unique_keys)  # \u8f93\u51fa: {&#39;city&#39;, &#39;age&#39;}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u516b\u3001\u4f7f\u7528\u5b57\u5178\u952e\u7684\u5bf9\u79f0\u5dee\u96c6<\/p>\n<\/p>\n<p><p>\u6709\u65f6\u53ef\u80fd\u9700\u8981\u83b7\u53d6\u4e24\u4e2a\u5b57\u5178\u4e2d\u4e0d\u540c\u7684\u952e\u3002\u53ef\u4ee5\u4f7f\u7528\u96c6\u5408\u7684\u5bf9\u79f0\u5dee\u96c6\u64cd\u4f5c\u6765\u5b9e\u73b0\u8fd9\u4e00\u70b9\u3002\u901a\u8fc7\u5c06\u6bcf\u4e2a\u5b57\u5178\u7684\u952e\u89c6\u56fe\u5bf9\u8c61\u8f6c\u6362\u4e3a\u96c6\u5408\uff0c\u7136\u540e\u4f7f\u7528\u96c6\u5408\u7684\u5bf9\u79f0\u5dee\u96c6\u65b9\u6cd5\uff0c\u53ef\u4ee5\u83b7\u53d6\u4e0d\u540c\u7684\u952e\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u521b\u5efa\u4e24\u4e2a\u5b57\u5178<\/p>\n<p>dict1 = {&#39;name&#39;: &#39;Alice&#39;, &#39;age&#39;: 25, &#39;city&#39;: &#39;New York&#39;}<\/p>\n<p>dict2 = {&#39;name&#39;: &#39;Bob&#39;, &#39;country&#39;: &#39;USA&#39;}<\/p>\n<h2><strong>\u4f7f\u7528\u96c6\u5408\u7684\u5bf9\u79f0\u5dee\u96c6\u64cd\u4f5c\u83b7\u53d6\u4e0d\u540c\u7684\u952e<\/strong><\/h2>\n<p>different_keys = set(dict1.keys()).symmetric_difference(dict2.keys())<\/p>\n<p>print(different_keys)  # \u8f93\u51fa: {&#39;city&#39;, &#39;age&#39;, &#39;country&#39;}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u603b\u7ed3<\/p>\n<\/p>\n<p><p>\u83b7\u53d6\u5b57\u5178\u4e2d\u7684\u952e\u662fPython\u7f16\u7a0b\u4e2d\u7684\u5e38\u89c1\u64cd\u4f5c\u3002\u4f7f\u7528dict.keys()\u65b9\u6cd5\u3001for\u5faa\u73af\u904d\u5386\u3001\u5217\u8868\u63a8\u5bfc\u5f0f\u3001dict.items()\u65b9\u6cd5\u3001\u96c6\u5408\u64cd\u4f5c\u7b49\u591a\u79cd\u65b9\u6cd5\uff0c\u53ef\u4ee5\u7075\u6d3b\u5730\u83b7\u53d6\u548c\u5904\u7406\u5b57\u5178\u4e2d\u7684\u952e\u3002\u6839\u636e\u5177\u4f53\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\uff0c\u53ef\u4ee5\u63d0\u9ad8\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u548c\u6548\u7387\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u63d0\u53d6\u5b57\u5178\u7684\u6240\u6709\u952e\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u5b57\u5178\u7684<code>keys()<\/code>\u65b9\u6cd5\u6765\u63d0\u53d6\u6240\u6709\u952e\u3002\u8fd9\u4e2a\u65b9\u6cd5\u4f1a\u8fd4\u56de\u4e00\u4e2a\u89c6\u56fe\u5bf9\u8c61\uff0c\u5305\u542b\u5b57\u5178\u4e2d\u6240\u6709\u7684\u952e\u3002\u53ef\u4ee5\u901a\u8fc7\u5c06\u8be5\u89c6\u56fe\u8f6c\u6362\u4e3a\u5217\u8868\u6765\u83b7\u53d6\u4e00\u4e2a\u5177\u4f53\u7684\u5217\u8868\u3002\u4f8b\u5982\uff1a  <\/p>\n<pre><code class=\"language-python\">my_dict = {&#39;name&#39;: &#39;Alice&#39;, &#39;age&#39;: 25, &#39;city&#39;: &#39;New York&#39;}\nkeys_list = list(my_dict.keys())\nprint(keys_list)  # \u8f93\u51fa: [&#39;name&#39;, &#39;age&#39;, &#39;city&#39;]\n<\/code><\/pre>\n<p><strong>\u662f\u5426\u53ef\u4ee5\u901a\u8fc7\u5faa\u73af\u904d\u5386\u5b57\u5178\u83b7\u53d6\u952e\uff1f<\/strong><br \/>\u5f53\u7136\u53ef\u4ee5\uff01\u901a\u8fc7\u5faa\u73af\u904d\u5386\u5b57\u5178\uff0c\u53ef\u4ee5\u76f4\u63a5\u8bbf\u95ee\u6bcf\u4e00\u4e2a\u952e\u3002\u4f7f\u7528<code>for<\/code>\u5faa\u73af\uff0c\u53ef\u4ee5\u8f7b\u677e\u5b9e\u73b0\u8fd9\u4e00\u70b9\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a  <\/p>\n<pre><code class=\"language-python\">my_dict = {&#39;name&#39;: &#39;Alice&#39;, &#39;age&#39;: 25, &#39;city&#39;: &#39;New York&#39;}\nfor key in my_dict:\n    print(key)  # \u8f93\u51fa\u6bcf\u4e00\u4e2a\u952e\n<\/code><\/pre>\n<p>\u8fd9\u79cd\u65b9\u5f0f\u4e0d\u4ec5\u7b80\u5355\uff0c\u800c\u4e14\u76f4\u89c2\uff0c\u9002\u5408\u521d\u5b66\u8005\u7406\u89e3\u5b57\u5178\u7684\u7ed3\u6784\u3002<\/p>\n<p><strong>\u5982\u4f55\u68c0\u67e5\u5b57\u5178\u4e2d\u662f\u5426\u5b58\u5728\u67d0\u4e2a\u7279\u5b9a\u7684\u952e\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u68c0\u67e5\u5b57\u5178\u4e2d\u662f\u5426\u5b58\u5728\u67d0\u4e2a\u952e\u975e\u5e38\u7b80\u5355\uff0c\u53ef\u4ee5\u4f7f\u7528<code>in<\/code>\u5173\u952e\u5b57\u3002\u5982\u679c\u952e\u5b58\u5728\uff0c\u8fd4\u56de<code>True<\/code>\uff0c\u5426\u5219\u8fd4\u56de<code>False<\/code>\u3002\u4f8b\u5982\uff1a  <\/p>\n<pre><code class=\"language-python\">my_dict = {&#39;name&#39;: &#39;Alice&#39;, &#39;age&#39;: 25, &#39;city&#39;: &#39;New York&#39;}\nis_present = &#39;age&#39; in my_dict\nprint(is_present)  # \u8f93\u51fa: True\n<\/code><\/pre>\n<p>\u8fd9\u79cd\u65b9\u6cd5\u975e\u5e38\u9ad8\u6548\uff0c\u9002\u5408\u5728\u5904\u7406\u5b57\u5178\u6570\u636e\u65f6\u8fdb\u884c\u5feb\u901f\u67e5\u627e\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python\u4e2d\uff0c\u83b7\u53d6\u5b57\u5178\u4e2d\u7684\u952e\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5\uff1a\u4f7f\u7528dict.keys()\u65b9\u6cd5\u3001\u4f7f\u7528for\u5faa\u73af\u904d\u5386\u3001\u4f7f\u7528 [&hellip;]","protected":false},"author":3,"featured_media":1097572,"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\/1097566"}],"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=1097566"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1097566\/revisions"}],"predecessor-version":[{"id":1097576,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1097566\/revisions\/1097576"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1097572"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1097566"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1097566"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1097566"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}