{"id":1174304,"date":"2025-01-15T17:15:48","date_gmt":"2025-01-15T09:15:48","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1174304.html"},"modified":"2025-01-15T17:15:50","modified_gmt":"2025-01-15T09:15:50","slug":"python%e5%a6%82%e4%bd%95%e5%88%a4%e6%96%adset%e7%9a%84%e5%a4%a7%e5%b0%8f-2","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1174304.html","title":{"rendered":"python\u5982\u4f55\u5224\u65adset\u7684\u5927\u5c0f"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/26075828\/67f5561a-e382-465c-bc0a-40425f78029b.webp\" alt=\"python\u5982\u4f55\u5224\u65adset\u7684\u5927\u5c0f\" \/><\/p>\n<p><p> \u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u5185\u7f6e\u7684<code>len()<\/code>\u51fd\u6570\u6765\u5224\u65ad\u96c6\u5408\uff08set\uff09\u7684\u5927\u5c0f\u3002<strong>\u4f7f\u7528<code>len()<\/code>\u51fd\u6570\u3001\u904d\u5386\u96c6\u5408\u5e76\u8ba1\u6570\u3001\u4f7f\u7528\u96c6\u5408\u7684\u5185\u7f6e\u65b9\u6cd5\u3001\u4f7f\u7528\u751f\u6210\u5668\u8868\u8fbe\u5f0f<\/strong>\u7b49\u90fd\u662f\u5224\u65ad\u96c6\u5408\u5927\u5c0f\u7684\u5e38\u89c1\u65b9\u6cd5\u3002<strong>\u4f7f\u7528<code>len()<\/code>\u51fd\u6570\u6765\u5224\u65ad\u96c6\u5408\u5927\u5c0f\u6700\u4e3a\u76f4\u63a5\u548c\u9ad8\u6548<\/strong>\u3002\u4e0b\u9762\u662f\u5bf9\u8fd9\u4e00\u70b9\u7684\u8be6\u7ec6\u63cf\u8ff0\uff1a<\/p>\n<\/p>\n<p><p><strong>\u4f7f\u7528<code>len()<\/code>\u51fd\u6570<\/strong>\uff1a<\/p>\n<p>\u8fd9\u662f\u6700\u7b80\u5355\u548c\u6700\u5e38\u7528\u7684\u65b9\u6cd5\u3002<code>len()<\/code>\u51fd\u6570\u662fPython\u7684\u5185\u7f6e\u51fd\u6570\uff0c\u53ef\u4ee5\u76f4\u63a5\u7528\u4e8e\u4efb\u4f55\u96c6\u5408\u7c7b\u578b\uff08\u5982list\u3001set\u3001dict\u7b49\uff09\u3002\u5b83\u7684\u65f6\u95f4\u590d\u6742\u5ea6\u4e3aO(1)\uff0c\u5373\u4f7f\u96c6\u5408\u975e\u5e38\u5927\uff0c\u8ba1\u7b97\u901f\u5ea6\u4e5f\u975e\u5e38\u5feb\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">my_set = {1, 2, 3, 4, 5}<\/p>\n<p>size = len(my_set)<\/p>\n<p>print(&quot;The size of the set is:&quot;, size)  # \u8f93\u51fa: The size of the set is: 5<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e00\u3001\u4f7f\u7528<code>len()<\/code>\u51fd\u6570\u5224\u65ad\u96c6\u5408\u5927\u5c0f<\/h3>\n<\/p>\n<p><p>\u5728Python\u4e2d\uff0c<code>len()<\/code>\u51fd\u6570\u662f\u4e00\u4e2a\u5185\u7f6e\u51fd\u6570\uff0c\u5b83\u53ef\u4ee5\u76f4\u63a5\u83b7\u53d6\u96c6\u5408\uff08set\uff09\u7684\u5927\u5c0f\u3002\u8fd9\u4e2a\u65b9\u6cd5\u6700\u4e3a\u76f4\u63a5\u548c\u9ad8\u6548\uff0c\u9002\u7528\u4e8e\u5927\u591a\u6570\u573a\u666f\u3002<\/p>\n<\/p>\n<p><h4>\u793a\u4f8b\u4ee3\u7801<\/h4>\n<\/p>\n<p><p>\u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\uff0c\u5c55\u793a\u4e86\u5982\u4f55\u4f7f\u7528<code>len()<\/code>\u51fd\u6570\u6765\u5224\u65ad\u96c6\u5408\u7684\u5927\u5c0f\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u5b9a\u4e49\u4e00\u4e2a\u96c6\u5408<\/p>\n<p>my_set = {1, 2, 3, 4, 5}<\/p>\n<h2><strong>\u4f7f\u7528len()\u51fd\u6570\u83b7\u53d6\u96c6\u5408\u7684\u5927\u5c0f<\/strong><\/h2>\n<p>size = len(my_set)<\/p>\n<h2><strong>\u8f93\u51fa\u96c6\u5408\u7684\u5927\u5c0f<\/strong><\/h2>\n<p>print(&quot;The size of the set is:&quot;, size)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c<code>len()<\/code>\u51fd\u6570\u7528\u4e8e\u83b7\u53d6\u96c6\u5408<code>my_set<\/code>\u7684\u5927\u5c0f\uff0c\u5e76\u5c06\u7ed3\u679c\u5b58\u50a8\u5728\u53d8\u91cf<code>size<\/code>\u4e2d\u3002\u6700\u540e\uff0c\u4f7f\u7528<code>print()<\/code>\u51fd\u6570\u8f93\u51fa\u96c6\u5408\u7684\u5927\u5c0f\u3002<\/p>\n<\/p>\n<p><h4>\u4f18\u52bf<\/h4>\n<\/p>\n<ol>\n<li><strong>\u7b80\u5355\u6613\u7528<\/strong>\uff1a<code>len()<\/code>\u51fd\u6570\u662fPython\u7684\u5185\u7f6e\u51fd\u6570\uff0c\u8bed\u6cd5\u7b80\u5355\uff0c\u6613\u4e8e\u7406\u89e3\u548c\u4f7f\u7528\u3002<\/li>\n<li><strong>\u9ad8\u6548<\/strong>\uff1a<code>len()<\/code>\u51fd\u6570\u7684\u65f6\u95f4\u590d\u6742\u5ea6\u4e3aO(1)\uff0c\u5373\u4f7f\u96c6\u5408\u975e\u5e38\u5927\uff0c\u8ba1\u7b97\u901f\u5ea6\u4e5f\u975e\u5e38\u5feb\u3002<\/li>\n<\/ol>\n<p><h3>\u4e8c\u3001\u904d\u5386\u96c6\u5408\u5e76\u8ba1\u6570<\/h3>\n<\/p>\n<p><p>\u9664\u4e86\u4f7f\u7528<code>len()<\/code>\u51fd\u6570\uff0c\u6211\u4eec\u8fd8\u53ef\u4ee5\u901a\u8fc7\u904d\u5386\u96c6\u5408\u5e76\u8ba1\u6570\u6765\u83b7\u53d6\u96c6\u5408\u7684\u5927\u5c0f\u3002\u867d\u7136\u8fd9\u79cd\u65b9\u6cd5\u4e0d\u5982\u4f7f\u7528<code>len()<\/code>\u51fd\u6570\u76f4\u63a5\uff0c\u4f46\u5728\u67d0\u4e9b\u7279\u6b8a\u573a\u666f\u4e0b\u53ef\u80fd\u4f1a\u6709\u7528\u3002<\/p>\n<\/p>\n<p><h4>\u793a\u4f8b\u4ee3\u7801<\/h4>\n<\/p>\n<p><p>\u4e0b\u9762\u662f\u4e00\u4e2a\u901a\u8fc7\u904d\u5386\u96c6\u5408\u5e76\u8ba1\u6570\u6765\u83b7\u53d6\u96c6\u5408\u5927\u5c0f\u7684\u4f8b\u5b50\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u5b9a\u4e49\u4e00\u4e2a\u96c6\u5408<\/p>\n<p>my_set = {1, 2, 3, 4, 5}<\/p>\n<h2><strong>\u521d\u59cb\u5316\u8ba1\u6570\u5668<\/strong><\/h2>\n<p>count = 0<\/p>\n<h2><strong>\u904d\u5386\u96c6\u5408\u5e76\u8ba1\u6570<\/strong><\/h2>\n<p>for item in my_set:<\/p>\n<p>    count += 1<\/p>\n<h2><strong>\u8f93\u51fa\u96c6\u5408\u7684\u5927\u5c0f<\/strong><\/h2>\n<p>print(&quot;The size of the set is:&quot;, count)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u9996\u5148\u521d\u59cb\u5316\u4e86\u4e00\u4e2a\u8ba1\u6570\u5668<code>count<\/code>\uff0c\u7136\u540e\u901a\u8fc7\u904d\u5386\u96c6\u5408<code>my_set<\/code>\uff0c\u6bcf\u904d\u5386\u4e00\u4e2a\u5143\u7d20\u5c31\u5c06\u8ba1\u6570\u5668\u52a01\u3002\u6700\u540e\uff0c\u4f7f\u7528<code>print()<\/code>\u51fd\u6570\u8f93\u51fa\u8ba1\u6570\u5668\u7684\u503c\uff0c\u5373\u96c6\u5408\u7684\u5927\u5c0f\u3002<\/p>\n<\/p>\n<p><h4>\u52a3\u52bf<\/h4>\n<\/p>\n<ol>\n<li><strong>\u6548\u7387\u8f83\u4f4e<\/strong>\uff1a\u76f8\u6bd4\u4e8e<code>len()<\/code>\u51fd\u6570\uff0c\u8fd9\u79cd\u65b9\u6cd5\u7684\u65f6\u95f4\u590d\u6742\u5ea6\u4e3aO(n)\uff0c\u5373\u9700\u8981\u904d\u5386\u6574\u4e2a\u96c6\u5408\u3002<\/li>\n<li><strong>\u4ee3\u7801\u590d\u6742\u5ea6\u8f83\u9ad8<\/strong>\uff1a\u76f8\u6bd4\u4e8e<code>len()<\/code>\u51fd\u6570\uff0c\u8fd9\u79cd\u65b9\u6cd5\u9700\u8981\u66f4\u591a\u7684\u4ee3\u7801\uff0c\u4e14\u53ef\u8bfb\u6027\u8f83\u5dee\u3002<\/li>\n<\/ol>\n<p><h3>\u4e09\u3001\u4f7f\u7528\u96c6\u5408\u7684\u5185\u7f6e\u65b9\u6cd5<\/h3>\n<\/p>\n<p><p>Python\u7684\u96c6\u5408\u7c7b\u578b\u6709\u4e00\u4e9b\u5185\u7f6e\u7684\u65b9\u6cd5\uff0c\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u83b7\u53d6\u96c6\u5408\u7684\u4fe1\u606f\u3002\u4e0d\u8fc7\uff0c\u76ee\u524dPython\u96c6\u5408\u5e76\u6ca1\u6709\u76f4\u63a5\u63d0\u4f9b\u83b7\u53d6\u96c6\u5408\u5927\u5c0f\u7684\u5185\u7f6e\u65b9\u6cd5\uff0c\u56e0\u6b64\u8fd9\u79cd\u65b9\u6cd5\u5728\u5224\u65ad\u96c6\u5408\u5927\u5c0f\u65b9\u9762\u5e76\u4e0d\u9002\u7528\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u4f7f\u7528\u751f\u6210\u5668\u8868\u8fbe\u5f0f<\/h3>\n<\/p>\n<p><p>\u751f\u6210\u5668\u8868\u8fbe\u5f0f\u662f\u4e00\u79cd\u7b80\u6d01\u7684\u8bed\u6cd5\uff0c\u53ef\u4ee5\u7528\u4e8e\u751f\u6210\u4e00\u4e2a\u751f\u6210\u5668\u5bf9\u8c61\u3002\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u751f\u6210\u5668\u8868\u8fbe\u5f0f\u6765\u751f\u6210\u96c6\u5408\u7684\u5143\u7d20\uff0c\u5e76\u8ba1\u6570\u6765\u83b7\u53d6\u96c6\u5408\u7684\u5927\u5c0f\u3002<\/p>\n<\/p>\n<p><h4>\u793a\u4f8b\u4ee3\u7801<\/h4>\n<\/p>\n<p><p>\u4e0b\u9762\u662f\u4e00\u4e2a\u901a\u8fc7\u751f\u6210\u5668\u8868\u8fbe\u5f0f\u6765\u83b7\u53d6\u96c6\u5408\u5927\u5c0f\u7684\u4f8b\u5b50\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u5b9a\u4e49\u4e00\u4e2a\u96c6\u5408<\/p>\n<p>my_set = {1, 2, 3, 4, 5}<\/p>\n<h2><strong>\u4f7f\u7528\u751f\u6210\u5668\u8868\u8fbe\u5f0f\u83b7\u53d6\u96c6\u5408\u7684\u5927\u5c0f<\/strong><\/h2>\n<p>size = sum(1 for _ in my_set)<\/p>\n<h2><strong>\u8f93\u51fa\u96c6\u5408\u7684\u5927\u5c0f<\/strong><\/h2>\n<p>print(&quot;The size of the set is:&quot;, size)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u751f\u6210\u5668\u8868\u8fbe\u5f0f<code>(1 for _ in my_set)<\/code>\u6765\u751f\u6210\u96c6\u5408\u7684\u5143\u7d20\uff0c\u5e76\u901a\u8fc7<code>sum()<\/code>\u51fd\u6570\u5bf9\u751f\u6210\u5668\u8868\u8fbe\u5f0f\u7684\u7ed3\u679c\u8fdb\u884c\u6c42\u548c\uff0c\u4ece\u800c\u83b7\u53d6\u96c6\u5408\u7684\u5927\u5c0f\u3002<\/p>\n<\/p>\n<p><h4>\u4f18\u52bf<\/h4>\n<\/p>\n<ol>\n<li><strong>\u4ee3\u7801\u7b80\u6d01<\/strong>\uff1a\u76f8\u6bd4\u4e8e\u904d\u5386\u96c6\u5408\u5e76\u8ba1\u6570\uff0c\u8fd9\u79cd\u65b9\u6cd5\u7684\u4ee3\u7801\u66f4\u52a0\u7b80\u6d01\u3002<\/li>\n<li><strong>\u9002\u7528\u6027\u5f3a<\/strong>\uff1a\u751f\u6210\u5668\u8868\u8fbe\u5f0f\u53ef\u4ee5\u7528\u4e8e\u4efb\u4f55\u53ef\u8fed\u4ee3\u5bf9\u8c61\uff0c\u4e0d\u4ec5\u9650\u4e8e\u96c6\u5408\u3002<\/li>\n<\/ol>\n<p><h3>\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u5728Python\u4e2d\uff0c\u5224\u65ad\u96c6\u5408\u7684\u5927\u5c0f\u6700\u76f4\u63a5\u548c\u9ad8\u6548\u7684\u65b9\u6cd5\u662f\u4f7f\u7528<code>len()<\/code>\u51fd\u6570\u3002\u8fd9\u79cd\u65b9\u6cd5\u4e0d\u4ec5\u8bed\u6cd5\u7b80\u5355\uff0c\u6613\u4e8e\u7406\u89e3\u548c\u4f7f\u7528\uff0c\u800c\u4e14\u6548\u7387\u6781\u9ad8\uff0c\u9002\u7528\u4e8e\u5927\u591a\u6570\u573a\u666f\u3002\u867d\u7136\u8fd8\u6709\u5176\u4ed6\u65b9\u6cd5\u53ef\u4ee5\u83b7\u53d6\u96c6\u5408\u7684\u5927\u5c0f\uff0c\u5982\u904d\u5386\u96c6\u5408\u5e76\u8ba1\u6570\u3001\u4f7f\u7528\u751f\u6210\u5668\u8868\u8fbe\u5f0f\u7b49\uff0c\u4f46\u8fd9\u4e9b\u65b9\u6cd5\u7684\u6548\u7387\u548c\u4ee3\u7801\u590d\u6742\u5ea6\u90fd\u4e0d\u5982<code>len()<\/code>\u51fd\u6570\uff0c\u56e0\u6b64\u5728\u5b9e\u9645\u5f00\u53d1\u4e2d\uff0c\u63a8\u8350\u4f18\u5148\u4f7f\u7528<code>len()<\/code>\u51fd\u6570\u6765\u5224\u65ad\u96c6\u5408\u7684\u5927\u5c0f\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001\u5176\u4ed6\u76f8\u5173\u7684\u96c6\u5408\u64cd\u4f5c<\/h3>\n<\/p>\n<p><p>\u9664\u4e86\u83b7\u53d6\u96c6\u5408\u7684\u5927\u5c0f\uff0cPython\u8fd8\u63d0\u4f9b\u4e86\u8bb8\u591a\u5176\u4ed6\u7684\u96c6\u5408\u64cd\u4f5c\uff0c\u8fd9\u4e9b\u64cd\u4f5c\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u66f4\u597d\u5730\u5904\u7406\u96c6\u5408\u6570\u636e\u3002\u4e0b\u9762\u4ecb\u7ecd\u4e00\u4e9b\u5e38\u89c1\u7684\u96c6\u5408\u64cd\u4f5c\u3002<\/p>\n<\/p>\n<p><h4>\u96c6\u5408\u7684\u6dfb\u52a0\u64cd\u4f5c<\/h4>\n<\/p>\n<p><p>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528<code>add()<\/code>\u65b9\u6cd5\u5411\u96c6\u5408\u4e2d\u6dfb\u52a0\u5143\u7d20\u3002\u5982\u679c\u6dfb\u52a0\u7684\u5143\u7d20\u5df2\u7ecf\u5b58\u5728\u4e8e\u96c6\u5408\u4e2d\uff0c\u96c6\u5408\u5c06\u4e0d\u4f1a\u53d1\u751f\u53d8\u5316\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u5b9a\u4e49\u4e00\u4e2a\u96c6\u5408<\/p>\n<p>my_set = {1, 2, 3}<\/p>\n<h2><strong>\u5411\u96c6\u5408\u4e2d\u6dfb\u52a0\u5143\u7d20<\/strong><\/h2>\n<p>my_set.add(4)<\/p>\n<h2><strong>\u8f93\u51fa\u96c6\u5408<\/strong><\/h2>\n<p>print(&quot;The updated set is:&quot;, my_set)  # \u8f93\u51fa: The updated set is: {1, 2, 3, 4}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u96c6\u5408\u7684\u5220\u9664\u64cd\u4f5c<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u4f7f\u7528<code>remove()<\/code>\u65b9\u6cd5\u6216<code>discard()<\/code>\u65b9\u6cd5\u4ece\u96c6\u5408\u4e2d\u5220\u9664\u5143\u7d20\u3002\u5982\u679c\u4f7f\u7528<code>remove()<\/code>\u65b9\u6cd5\u5220\u9664\u4e0d\u5b58\u5728\u7684\u5143\u7d20\uff0c\u5c06\u4f1a\u629b\u51faKeyError\u5f02\u5e38\uff1b\u800c\u4f7f\u7528<code>discard()<\/code>\u65b9\u6cd5\u5220\u9664\u4e0d\u5b58\u5728\u7684\u5143\u7d20\uff0c\u5219\u4e0d\u4f1a\u629b\u51fa\u5f02\u5e38\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u5b9a\u4e49\u4e00\u4e2a\u96c6\u5408<\/p>\n<p>my_set = {1, 2, 3, 4}<\/p>\n<h2><strong>\u4f7f\u7528remove()\u65b9\u6cd5\u5220\u9664\u5143\u7d20<\/strong><\/h2>\n<p>my_set.remove(4)<\/p>\n<h2><strong>\u4f7f\u7528discard()\u65b9\u6cd5\u5220\u9664\u5143\u7d20<\/strong><\/h2>\n<p>my_set.discard(3)<\/p>\n<h2><strong>\u8f93\u51fa\u96c6\u5408<\/strong><\/h2>\n<p>print(&quot;The updated set is:&quot;, my_set)  # \u8f93\u51fa: The updated set is: {1, 2}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u96c6\u5408\u7684\u8054\u5408\u64cd\u4f5c<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u4f7f\u7528<code>union()<\/code>\u65b9\u6cd5\u6216<code>|<\/code>\u8fd0\u7b97\u7b26\u6765\u8fdb\u884c\u96c6\u5408\u7684\u8054\u5408\u64cd\u4f5c\uff0c\u8fd4\u56de\u4e00\u4e2a\u5305\u542b\u4e24\u4e2a\u96c6\u5408\u6240\u6709\u5143\u7d20\u7684\u65b0\u96c6\u5408\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u5b9a\u4e49\u4e24\u4e2a\u96c6\u5408<\/p>\n<p>set1 = {1, 2, 3}<\/p>\n<p>set2 = {3, 4, 5}<\/p>\n<h2><strong>\u4f7f\u7528union()\u65b9\u6cd5\u8fdb\u884c\u96c6\u5408\u8054\u5408<\/strong><\/h2>\n<p>union_set = set1.union(set2)<\/p>\n<h2><strong>\u4f7f\u7528|\u8fd0\u7b97\u7b26\u8fdb\u884c\u96c6\u5408\u8054\u5408<\/strong><\/h2>\n<p>union_set = set1 | set2<\/p>\n<h2><strong>\u8f93\u51fa\u8054\u5408\u540e\u7684\u96c6\u5408<\/strong><\/h2>\n<p>print(&quot;The union set is:&quot;, union_set)  # \u8f93\u51fa: The union set is: {1, 2, 3, 4, 5}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u96c6\u5408\u7684\u4ea4\u96c6\u64cd\u4f5c<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u4f7f\u7528<code>intersection()<\/code>\u65b9\u6cd5\u6216<code>&amp;<\/code>\u8fd0\u7b97\u7b26\u6765\u8fdb\u884c\u96c6\u5408\u7684\u4ea4\u96c6\u64cd\u4f5c\uff0c\u8fd4\u56de\u4e00\u4e2a\u5305\u542b\u4e24\u4e2a\u96c6\u5408\u516c\u5171\u5143\u7d20\u7684\u65b0\u96c6\u5408\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u5b9a\u4e49\u4e24\u4e2a\u96c6\u5408<\/p>\n<p>set1 = {1, 2, 3}<\/p>\n<p>set2 = {3, 4, 5}<\/p>\n<h2><strong>\u4f7f\u7528intersection()\u65b9\u6cd5\u8fdb\u884c\u96c6\u5408\u4ea4\u96c6<\/strong><\/h2>\n<p>intersection_set = set1.intersection(set2)<\/p>\n<h2><strong>\u4f7f\u7528&amp;\u8fd0\u7b97\u7b26\u8fdb\u884c\u96c6\u5408\u4ea4\u96c6<\/strong><\/h2>\n<p>intersection_set = set1 &amp; set2<\/p>\n<h2><strong>\u8f93\u51fa\u4ea4\u96c6\u540e\u7684\u96c6\u5408<\/strong><\/h2>\n<p>print(&quot;The intersection set is:&quot;, intersection_set)  # \u8f93\u51fa: The intersection set is: {3}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u96c6\u5408\u7684\u5dee\u96c6\u64cd\u4f5c<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u4f7f\u7528<code>difference()<\/code>\u65b9\u6cd5\u6216<code>-<\/code>\u8fd0\u7b97\u7b26\u6765\u8fdb\u884c\u96c6\u5408\u7684\u5dee\u96c6\u64cd\u4f5c\uff0c\u8fd4\u56de\u4e00\u4e2a\u5305\u542b\u7b2c\u4e00\u4e2a\u96c6\u5408\u4e2d\u4e0d\u5c5e\u4e8e\u7b2c\u4e8c\u4e2a\u96c6\u5408\u7684\u5143\u7d20\u7684\u65b0\u96c6\u5408\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u5b9a\u4e49\u4e24\u4e2a\u96c6\u5408<\/p>\n<p>set1 = {1, 2, 3}<\/p>\n<p>set2 = {3, 4, 5}<\/p>\n<h2><strong>\u4f7f\u7528difference()\u65b9\u6cd5\u8fdb\u884c\u96c6\u5408\u5dee\u96c6<\/strong><\/h2>\n<p>difference_set = set1.difference(set2)<\/p>\n<h2><strong>\u4f7f\u7528-\u8fd0\u7b97\u7b26\u8fdb\u884c\u96c6\u5408\u5dee\u96c6<\/strong><\/h2>\n<p>difference_set = set1 - set2<\/p>\n<h2><strong>\u8f93\u51fa\u5dee\u96c6\u540e\u7684\u96c6\u5408<\/strong><\/h2>\n<p>print(&quot;The difference set is:&quot;, difference_set)  # \u8f93\u51fa: The difference set is: {1, 2}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u96c6\u5408\u7684\u5bf9\u79f0\u5dee\u96c6\u64cd\u4f5c<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u4f7f\u7528<code>symmetric_difference()<\/code>\u65b9\u6cd5\u6216<code>^<\/code>\u8fd0\u7b97\u7b26\u6765\u8fdb\u884c\u96c6\u5408\u7684\u5bf9\u79f0\u5dee\u96c6\u64cd\u4f5c\uff0c\u8fd4\u56de\u4e00\u4e2a\u5305\u542b\u4e24\u4e2a\u96c6\u5408\u4e2d\u4e0d\u5c5e\u4e8e\u5f7c\u6b64\u7684\u5143\u7d20\u7684\u65b0\u96c6\u5408\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u5b9a\u4e49\u4e24\u4e2a\u96c6\u5408<\/p>\n<p>set1 = {1, 2, 3}<\/p>\n<p>set2 = {3, 4, 5}<\/p>\n<h2><strong>\u4f7f\u7528symmetric_difference()\u65b9\u6cd5\u8fdb\u884c\u96c6\u5408\u5bf9\u79f0\u5dee\u96c6<\/strong><\/h2>\n<p>symmetric_difference_set = set1.symmetric_difference(set2)<\/p>\n<h2><strong>\u4f7f\u7528^\u8fd0\u7b97\u7b26\u8fdb\u884c\u96c6\u5408\u5bf9\u79f0\u5dee\u96c6<\/strong><\/h2>\n<p>symmetric_difference_set = set1 ^ set2<\/p>\n<h2><strong>\u8f93\u51fa\u5bf9\u79f0\u5dee\u96c6\u540e\u7684\u96c6\u5408<\/strong><\/h2>\n<p>print(&quot;The symmetric difference set is:&quot;, symmetric_difference_set)  # \u8f93\u51fa: The symmetric difference set is: {1, 2, 4, 5}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u516d\u3001\u96c6\u5408\u7684\u5176\u4ed6\u9ad8\u7ea7\u64cd\u4f5c<\/h3>\n<\/p>\n<p><p>Python\u96c6\u5408\u8fd8\u652f\u6301\u4e00\u4e9b\u9ad8\u7ea7\u64cd\u4f5c\uff0c\u5982\u5b50\u96c6\u548c\u8d85\u96c6\u7684\u5224\u65ad\u3001\u96c6\u5408\u7684\u51bb\u7ed3\u7b49\uff0c\u8fd9\u4e9b\u64cd\u4f5c\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u66f4\u7075\u6d3b\u5730\u5904\u7406\u96c6\u5408\u6570\u636e\u3002<\/p>\n<\/p>\n<p><h4>\u5224\u65ad\u5b50\u96c6\u548c\u8d85\u96c6<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u4f7f\u7528<code>issubset()<\/code>\u65b9\u6cd5\u6765\u5224\u65ad\u4e00\u4e2a\u96c6\u5408\u662f\u5426\u4e3a\u53e6\u4e00\u4e2a\u96c6\u5408\u7684\u5b50\u96c6\uff0c\u4f7f\u7528<code>issuperset()<\/code>\u65b9\u6cd5\u6765\u5224\u65ad\u4e00\u4e2a\u96c6\u5408\u662f\u5426\u4e3a\u53e6\u4e00\u4e2a\u96c6\u5408\u7684\u8d85\u96c6\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u5b9a\u4e49\u4e24\u4e2a\u96c6\u5408<\/p>\n<p>set1 = {1, 2, 3}<\/p>\n<p>set2 = {1, 2, 3, 4, 5}<\/p>\n<h2><strong>\u5224\u65adset1\u662f\u5426\u4e3aset2\u7684\u5b50\u96c6<\/strong><\/h2>\n<p>is_subset = set1.issubset(set2)<\/p>\n<h2><strong>\u5224\u65adset2\u662f\u5426\u4e3aset1\u7684\u8d85\u96c6<\/strong><\/h2>\n<p>is_superset = set2.issuperset(set1)<\/p>\n<h2><strong>\u8f93\u51fa\u5224\u65ad\u7ed3\u679c<\/strong><\/h2>\n<p>print(&quot;Is set1 a subset of set2?&quot;, is_subset)  # \u8f93\u51fa: Is set1 a subset of set2? True<\/p>\n<p>print(&quot;Is set2 a superset of set1?&quot;, is_superset)  # \u8f93\u51fa: Is set2 a superset of set1? True<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u51bb\u7ed3\u96c6\u5408<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u4f7f\u7528<code>frozenset<\/code>\u6765\u521b\u5efa\u4e00\u4e2a\u4e0d\u53ef\u53d8\u7684\u96c6\u5408\uff08\u51bb\u7ed3\u96c6\u5408\uff09\u3002\u51bb\u7ed3\u96c6\u5408\u4e00\u65e6\u521b\u5efa\uff0c\u5c31\u4e0d\u80fd\u518d\u4fee\u6539\uff0c\u5176\u884c\u4e3a\u7c7b\u4f3c\u4e8e\u5143\u7ec4\u5bf9\u4e8e\u5217\u8868\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u5b9a\u4e49\u4e00\u4e2a\u96c6\u5408<\/p>\n<p>my_set = {1, 2, 3}<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2a\u51bb\u7ed3\u96c6\u5408<\/strong><\/h2>\n<p>frozen_set = frozenset(my_set)<\/p>\n<h2><strong>\u8f93\u51fa\u51bb\u7ed3\u96c6\u5408<\/strong><\/h2>\n<p>print(&quot;The frozen set is:&quot;, frozen_set)  # \u8f93\u51fa: The frozen set is: frozenset({1, 2, 3})<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u51bb\u7ed3\u96c6\u5408\u53ef\u4ee5\u7528\u4e8e\u9700\u8981\u4e0d\u53ef\u53d8\u96c6\u5408\u7684\u573a\u666f\uff0c\u5982\u4f5c\u4e3a\u5b57\u5178\u7684\u952e\u6216\u96c6\u5408\u7684\u5143\u7d20\u3002<\/p>\n<\/p>\n<p><h3>\u4e03\u3001\u96c6\u5408\u7684\u5e94\u7528\u573a\u666f<\/h3>\n<\/p>\n<p><p>\u96c6\u5408\u5728Python\u4e2d\u6709\u8bb8\u591a\u5b9e\u9645\u5e94\u7528\u573a\u666f\uff0c\u4e0b\u9762\u4ecb\u7ecd\u4e00\u4e9b\u5e38\u89c1\u7684\u5e94\u7528\u573a\u666f\u3002<\/p>\n<\/p>\n<p><h4>\u53bb\u91cd<\/h4>\n<\/p>\n<p><p>\u96c6\u5408\u7684\u4e00\u4e2a\u91cd\u8981\u7279\u6027\u662f\u5176\u5143\u7d20\u7684\u552f\u4e00\u6027\uff0c\u56e0\u6b64\u96c6\u5408\u53ef\u4ee5\u7528\u4e8e\u53bb\u91cd\u64cd\u4f5c\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u5b9a\u4e49\u4e00\u4e2a\u5305\u542b\u91cd\u590d\u5143\u7d20\u7684\u5217\u8868<\/p>\n<p>my_list = [1, 2, 2, 3, 4, 4, 5]<\/p>\n<h2><strong>\u4f7f\u7528\u96c6\u5408\u53bb\u91cd<\/strong><\/h2>\n<p>unique_list = list(set(my_list))<\/p>\n<h2><strong>\u8f93\u51fa\u53bb\u91cd\u540e\u7684\u5217\u8868<\/strong><\/h2>\n<p>print(&quot;The unique list is:&quot;, unique_list)  # \u8f93\u51fa: The unique list is: [1, 2, 3, 4, 5]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u96c6\u5408\u8fd0\u7b97<\/h4>\n<\/p>\n<p><p>\u96c6\u5408\u8fd0\u7b97\uff08\u5982\u8054\u5408\u3001\u4ea4\u96c6\u3001\u5dee\u96c6\u548c\u5bf9\u79f0\u5dee\u96c6\uff09\u5728\u8bb8\u591a\u6570\u636e\u5904\u7406\u573a\u666f\u4e2d\u975e\u5e38\u6709\u7528\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u7528\u6765\u67e5\u627e\u4e24\u4e2a\u96c6\u5408\u7684\u516c\u5171\u5143\u7d20\u6216\u4e0d\u540c\u5143\u7d20\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u5b9a\u4e49\u4e24\u4e2a\u96c6\u5408<\/p>\n<p>set1 = {&quot;apple&quot;, &quot;banana&quot;, &quot;cherry&quot;}<\/p>\n<p>set2 = {&quot;banana&quot;, &quot;cherry&quot;, &quot;date&quot;}<\/p>\n<h2><strong>\u67e5\u627e\u4e24\u4e2a\u96c6\u5408\u7684\u516c\u5171\u5143\u7d20\uff08\u4ea4\u96c6\uff09<\/strong><\/h2>\n<p>common_elements = set1 &amp; set2<\/p>\n<h2><strong>\u67e5\u627e\u4e24\u4e2a\u96c6\u5408\u7684\u4e0d\u540c\u5143\u7d20\uff08\u5dee\u96c6\uff09<\/strong><\/h2>\n<p>different_elements = set1 - set2<\/p>\n<h2><strong>\u8f93\u51fa\u7ed3\u679c<\/strong><\/h2>\n<p>print(&quot;Common elements:&quot;, common_elements)  # \u8f93\u51fa: Common elements: {&#39;banana&#39;, &#39;cherry&#39;}<\/p>\n<p>print(&quot;Different elements:&quot;, different_elements)  # \u8f93\u51fa: Different elements: {&#39;apple&#39;}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u5224\u65ad\u5143\u7d20\u662f\u5426\u5b58\u5728<\/h4>\n<\/p>\n<p><p>\u96c6\u5408\u7684\u67e5\u627e\u64cd\u4f5c\u5177\u6709O(1)\u7684\u65f6\u95f4\u590d\u6742\u5ea6\uff0c\u975e\u5e38\u9ad8\u6548\uff0c\u56e0\u6b64\u53ef\u4ee5\u7528\u4e8e\u5224\u65ad\u5143\u7d20\u662f\u5426\u5b58\u5728\u4e8e\u96c6\u5408\u4e2d\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u5b9a\u4e49\u4e00\u4e2a\u96c6\u5408<\/p>\n<p>my_set = {1, 2, 3, 4, 5}<\/p>\n<h2><strong>\u5224\u65ad\u5143\u7d20\u662f\u5426\u5b58\u5728\u4e8e\u96c6\u5408\u4e2d<\/strong><\/h2>\n<p>is_present = 3 in my_set<\/p>\n<h2><strong>\u8f93\u51fa\u5224\u65ad\u7ed3\u679c<\/strong><\/h2>\n<p>print(&quot;Is 3 present in the set?&quot;, is_present)  # \u8f93\u51fa: Is 3 present in the set? True<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u516b\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u672c\u6587\u8be6\u7ec6\u4ecb\u7ecd\u4e86\u5982\u4f55\u5728Python\u4e2d\u5224\u65ad\u96c6\u5408\u7684\u5927\u5c0f\uff0c\u4ee5\u53ca\u5176\u4ed6\u4e00\u4e9b\u5e38\u89c1\u7684\u96c6\u5408\u64cd\u4f5c\u3002\u901a\u8fc7\u4f7f\u7528\u5185\u7f6e\u7684<code>len()<\/code>\u51fd\u6570\uff0c\u6211\u4eec\u53ef\u4ee5\u9ad8\u6548\u5730\u83b7\u53d6\u96c6\u5408\u7684\u5927\u5c0f\u3002\u6b64\u5916\uff0c\u6211\u4eec\u8fd8\u8ba8\u8bba\u4e86\u904d\u5386\u96c6\u5408\u5e76\u8ba1\u6570\u3001\u4f7f\u7528\u751f\u6210\u5668\u8868\u8fbe\u5f0f\u7b49\u5176\u4ed6\u65b9\u6cd5\u6765\u83b7\u53d6\u96c6\u5408\u7684\u5927\u5c0f\u3002\u5728\u5b9e\u9645\u5f00\u53d1\u4e2d\uff0c\u63a8\u8350\u4f18\u5148\u4f7f\u7528<code>len()<\/code>\u51fd\u6570\u6765\u5224\u65ad\u96c6\u5408\u7684\u5927\u5c0f\uff0c\u56e0\u4e3a\u5b83\u4e0d\u4ec5\u7b80\u5355\u6613\u7528\uff0c\u800c\u4e14\u6548\u7387\u6781\u9ad8\u3002<\/p>\n<\/p>\n<p><p>\u9664\u4e86\u83b7\u53d6\u96c6\u5408\u7684\u5927\u5c0f\uff0c\u672c\u6587\u8fd8\u4ecb\u7ecd\u4e86\u96c6\u5408\u7684\u4e00\u4e9b\u5e38\u89c1\u64cd\u4f5c\uff0c\u5982\u6dfb\u52a0\u3001\u5220\u9664\u3001\u8054\u5408\u3001\u4ea4\u96c6\u3001\u5dee\u96c6\u548c\u5bf9\u79f0\u5dee\u96c6\u7b49\u3002\u8fd9\u4e9b\u64cd\u4f5c\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u66f4\u597d\u5730\u5904\u7406\u96c6\u5408\u6570\u636e\u3002\u6700\u540e\uff0c\u672c\u6587\u8fd8\u4ecb\u7ecd\u4e86\u4e00\u4e9b\u96c6\u5408\u7684\u9ad8\u7ea7\u64cd\u4f5c\u548c\u5b9e\u9645\u5e94\u7528\u573a\u666f\uff0c\u5982\u5b50\u96c6\u548c\u8d85\u96c6\u7684\u5224\u65ad\u3001\u51bb\u7ed3\u96c6\u5408\u3001\u53bb\u91cd\u3001\u96c6\u5408\u8fd0\u7b97\u548c\u5224\u65ad\u5143\u7d20\u662f\u5426\u5b58\u5728\u7b49\u3002<\/p>\n<\/p>\n<p><p>\u901a\u8fc7\u638c\u63e1\u8fd9\u4e9b\u96c6\u5408\u64cd\u4f5c\uff0c\u6211\u4eec\u53ef\u4ee5\u66f4\u7075\u6d3b\u5730\u5904\u7406\u6570\u636e\uff0c\u63d0\u9ad8\u4ee3\u7801\u7684\u6548\u7387\u548c\u53ef\u8bfb\u6027\u3002\u5e0c\u671b\u672c\u6587\u5bf9\u4f60\u5728Python\u7f16\u7a0b\u4e2d\u7684\u96c6\u5408\u64cd\u4f5c\u6709\u6240\u5e2e\u52a9\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u83b7\u53d6\u4e00\u4e2a\u96c6\u5408\u7684\u5143\u7d20\u6570\u91cf\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u83b7\u53d6\u96c6\u5408\u7684\u5927\u5c0f\u975e\u5e38\u7b80\u5355\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528\u5185\u7f6e\u7684<code>len()<\/code>\u51fd\u6570\u6765\u83b7\u53d6\u96c6\u5408\u4e2d\u5143\u7d20\u7684\u6570\u91cf\u3002\u4f8b\u5982\uff0c\u5982\u679c\u4f60\u6709\u4e00\u4e2a\u96c6\u5408<code>my_set = {1, 2, 3, 4}<\/code>, \u4f60\u53ef\u4ee5\u901a\u8fc7<code>len(my_set)<\/code>\u6765\u5f97\u5230\u96c6\u5408\u7684\u5927\u5c0f\uff0c\u8fd9\u91cc\u8fd4\u56de\u7684\u7ed3\u679c\u662f4\u3002<\/p>\n<p><strong>\u96c6\u5408\u7684\u5927\u5c0f\u662f\u5426\u4f1a\u5f71\u54cd\u5176\u6027\u80fd\uff1f<\/strong><br \/>\u96c6\u5408\u7684\u5927\u5c0f\u4f1a\u5bf9\u6027\u80fd\u4ea7\u751f\u4e00\u5b9a\u7684\u5f71\u54cd\u3002\u901a\u5e38\u6765\u8bf4\uff0c\u96c6\u5408\u7684\u67e5\u627e\u548c\u63d2\u5165\u64cd\u4f5c\u7684\u65f6\u95f4\u590d\u6742\u5ea6\u662fO(1)\uff0c\u8fd9\u4f7f\u5f97\u5373\u4f7f\u5728\u96c6\u5408\u8f83\u5927\u65f6\uff0c\u64cd\u4f5c\u7684\u6548\u7387\u4ecd\u7136\u76f8\u5bf9\u8f83\u9ad8\u3002\u7136\u800c\uff0c\u968f\u7740\u96c6\u5408\u7684\u5927\u5c0f\u589e\u52a0\uff0c\u5185\u5b58\u7684\u4f7f\u7528\u548c\u64cd\u4f5c\u7684\u65f6\u95f4\u53ef\u80fd\u4f1a\u6709\u6240\u589e\u52a0\uff0c\u56e0\u6b64\u5728\u5904\u7406\u975e\u5e38\u5927\u7684\u96c6\u5408\u65f6\uff0c\u6ce8\u610f\u5185\u5b58\u7ba1\u7406\u548c\u6027\u80fd\u4f18\u5316\u662f\u975e\u5e38\u91cd\u8981\u7684\u3002<\/p>\n<p><strong>\u5728Python\u4e2d\uff0c\u5982\u4f55\u5224\u65ad\u4e00\u4e2a\u96c6\u5408\u662f\u5426\u4e3a\u7a7a\uff1f<\/strong><br \/>\u5224\u65ad\u96c6\u5408\u662f\u5426\u4e3a\u7a7a\u540c\u6837\u7b80\u5355\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528<code>len()<\/code>\u51fd\u6570\u68c0\u67e5\u96c6\u5408\u7684\u5927\u5c0f\uff0c\u6216\u8005\u76f4\u63a5\u4f7f\u7528\u6761\u4ef6\u8bed\u53e5\u3002\u6bd4\u5982\uff0c<code>if not my_set:<\/code>\u53ef\u4ee5\u7528\u6765\u5224\u65ad<code>my_set<\/code>\u662f\u5426\u4e3a\u7a7a\u3002\u5982\u679c\u96c6\u5408\u4e3a\u7a7a\uff0c\u6761\u4ef6\u4e3a\u771f\uff0c\u4ee3\u7801\u5757\u5185\u7684\u5185\u5bb9\u5c06\u4f1a\u6267\u884c\u3002\u8fd9\u6837\u53ef\u4ee5\u6709\u6548\u5730\u5224\u65ad\u96c6\u5408\u7684\u72b6\u6001\uff0c\u800c\u4e0d\u9700\u8981\u663e\u5f0f\u5730\u6bd4\u8f83\u5176\u957f\u5ea6\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u5185\u7f6e\u7684len()\u51fd\u6570\u6765\u5224\u65ad\u96c6\u5408\uff08set\uff09\u7684\u5927\u5c0f\u3002\u4f7f\u7528len()\u51fd\u6570\u3001\u904d\u5386\u96c6\u5408\u5e76\u8ba1\u6570\u3001 [&hellip;]","protected":false},"author":3,"featured_media":1174310,"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\/1174304"}],"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=1174304"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1174304\/revisions"}],"predecessor-version":[{"id":1174311,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1174304\/revisions\/1174311"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1174310"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1174304"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1174304"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1174304"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}