{"id":1077315,"date":"2025-01-08T12:01:14","date_gmt":"2025-01-08T04:01:14","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1077315.html"},"modified":"2025-01-08T12:01:16","modified_gmt":"2025-01-08T04:01:16","slug":"python%e4%b8%ad%e5%a6%82%e4%bd%95%e7%bb%9f%e8%ae%a1%e6%9c%89%e6%95%88%e7%a5%a8%e5%bc%a0%e6%95%b0-2","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1077315.html","title":{"rendered":"python\u4e2d\u5982\u4f55\u7edf\u8ba1\u6709\u6548\u7968\u5f20\u6570"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24181428\/4dc274ae-3898-4613-9a9d-1edbd15e4371.webp\" alt=\"python\u4e2d\u5982\u4f55\u7edf\u8ba1\u6709\u6548\u7968\u5f20\u6570\" \/><\/p>\n<p><p> <strong>\u7edf\u8ba1\u6709\u6548\u7968\u5f20\u6570<\/strong><\/p>\n<\/p>\n<p><p>\u5728Python\u4e2d\u7edf\u8ba1\u6709\u6548\u7968\u5f20\u6570\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u65b9\u6cd5\u5b9e\u73b0\u3002<strong>\u4f7f\u7528\u96c6\u5408\u6216\u5b57\u5178\u3001\u904d\u5386\u6570\u636e\u3001\u8fc7\u6ee4\u65e0\u6548\u7968\u5f20<\/strong>\u90fd\u662f\u5b9e\u73b0\u7edf\u8ba1\u7684\u6709\u6548\u65b9\u5f0f\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u8be6\u7ec6\u63cf\u8ff0\u5176\u4e2d\u4e00\u79cd\u65b9\u6cd5\uff0c\u5373\u4f7f\u7528\u5b57\u5178\u6765\u7edf\u8ba1\u6709\u6548\u7968\u5f20\u6570\u3002<\/p>\n<\/p>\n<p><p><strong>\u4f7f\u7528\u5b57\u5178\u7edf\u8ba1\u6709\u6548\u7968\u5f20\u6570<\/strong><\/p>\n<\/p>\n<p><p>\u4f7f\u7528\u5b57\u5178\u662f\u4e00\u79cd\u9ad8\u6548\u4e14\u6613\u4e8e\u7406\u89e3\u7684\u65b9\u6cd5\u3002\u5b57\u5178\u5141\u8bb8\u6211\u4eec\u5c06\u7968\u636e\u7f16\u53f7\u6620\u5c04\u5230\u5176\u6709\u6548\u6027\u72b6\u6001\uff0c\u4ece\u800c\u5feb\u901f\u7edf\u8ba1\u6709\u6548\u7968\u5f20\u6570\u3002\u4ee5\u4e0b\u662f\u5b9e\u73b0\u8fd9\u4e00\u65b9\u6cd5\u7684\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u5b9a\u4e49\u7968\u636e\u6570\u636e<\/p>\n<p>\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u5b9a\u4e49\u4e00\u4e2a\u7968\u636e\u6570\u636e\u5217\u8868\uff0c\u5176\u4e2d\u5305\u542b\u6240\u6709\u7968\u636e\u53ca\u5176\u6709\u6548\u6027\u72b6\u6001\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u5217\u8868\u6216\u5176\u4ed6\u6570\u636e\u7ed3\u6784\u6765\u5b58\u50a8\u8fd9\u4e9b\u6570\u636e\uff0c\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">tickets = [<\/p>\n<p>    {&quot;ticket_id&quot;: 1, &quot;valid&quot;: True},<\/p>\n<p>    {&quot;ticket_id&quot;: 2, &quot;valid&quot;: False},<\/p>\n<p>    {&quot;ticket_id&quot;: 3, &quot;valid&quot;: True},<\/p>\n<p>    {&quot;ticket_id&quot;: 4, &quot;valid&quot;: True},<\/p>\n<p>    {&quot;ticket_id&quot;: 5, &quot;valid&quot;: False}<\/p>\n<p>]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4e8c\u3001\u904d\u5386\u7968\u636e\u6570\u636e<\/p>\n<p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u9700\u8981\u904d\u5386\u7968\u636e\u6570\u636e\uff0c\u5e76\u4f7f\u7528\u4e00\u4e2a\u5b57\u5178\u6765\u7edf\u8ba1\u6bcf\u79cd\u72b6\u6001\u7684\u7968\u5f20\u6570\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">ticket_stats = {&quot;valid&quot;: 0, &quot;invalid&quot;: 0}<\/p>\n<p>for ticket in tickets:<\/p>\n<p>    if ticket[&quot;valid&quot;]:<\/p>\n<p>        ticket_stats[&quot;valid&quot;] += 1<\/p>\n<p>    else:<\/p>\n<p>        ticket_stats[&quot;invalid&quot;] += 1<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4e09\u3001\u8f93\u51fa\u7edf\u8ba1\u7ed3\u679c<\/p>\n<p>\u6700\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u8f93\u51fa\u7edf\u8ba1\u7ed3\u679c\uff0c\u4ee5\u67e5\u770b\u6709\u6548\u7968\u5f20\u6570\u548c\u65e0\u6548\u7968\u5f20\u6570\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">print(f&quot;\u6709\u6548\u7968\u5f20\u6570: {ticket_stats[&#39;valid&#39;]}&quot;)<\/p>\n<p>print(f&quot;\u65e0\u6548\u7968\u5f20\u6570: {ticket_stats[&#39;invalid&#39;]}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u6211\u4eec\u53ef\u4ee5\u8f7b\u677e\u7edf\u8ba1\u6709\u6548\u7968\u5f20\u6570\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u8be6\u7ec6\u8ba8\u8bba\u5176\u4ed6\u7edf\u8ba1\u6709\u6548\u7968\u5f20\u6570\u7684\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u4f7f\u7528\u96c6\u5408\u7edf\u8ba1<\/h3>\n<\/p>\n<p><p>\u96c6\u5408\u662f\u4e00\u79cd\u9ad8\u6548\u7684\u6570\u636e\u7ed3\u6784\uff0c\u9002\u5408\u7528\u4e8e\u53bb\u91cd\u548c\u68c0\u67e5\u5143\u7d20\u662f\u5426\u5b58\u5728\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u96c6\u5408\u6765\u5b58\u50a8\u6709\u6548\u7968\u636e\u7684\u7f16\u53f7\uff0c\u5e76\u7edf\u8ba1\u96c6\u5408\u7684\u5927\u5c0f\u6765\u83b7\u53d6\u6709\u6548\u7968\u5f20\u6570\u3002<\/p>\n<\/p>\n<p><p><strong>\u5b9a\u4e49\u7968\u636e\u6570\u636e<\/strong><\/p>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u6211\u4eec\u5b9a\u4e49\u4e00\u4e2a\u5305\u542b\u6240\u6709\u7968\u636e\u7f16\u53f7\u53ca\u5176\u6709\u6548\u6027\u72b6\u6001\u7684\u5217\u8868\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">tickets = [<\/p>\n<p>    {&quot;ticket_id&quot;: 1, &quot;valid&quot;: True},<\/p>\n<p>    {&quot;ticket_id&quot;: 2, &quot;valid&quot;: False},<\/p>\n<p>    {&quot;ticket_id&quot;: 3, &quot;valid&quot;: True},<\/p>\n<p>    {&quot;ticket_id&quot;: 4, &quot;valid&quot;: True},<\/p>\n<p>    {&quot;ticket_id&quot;: 5, &quot;valid&quot;: False}<\/p>\n<p>]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>\u904d\u5386\u7968\u636e\u6570\u636e\u5e76\u6dfb\u52a0\u5230\u96c6\u5408<\/strong><\/p>\n<\/p>\n<p><p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u904d\u5386\u7968\u636e\u6570\u636e\uff0c\u5e76\u5c06\u6709\u6548\u7684\u7968\u636e\u7f16\u53f7\u6dfb\u52a0\u5230\u96c6\u5408\u4e2d\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">valid_tickets = set()<\/p>\n<p>for ticket in tickets:<\/p>\n<p>    if ticket[&quot;valid&quot;]:<\/p>\n<p>        valid_tickets.add(ticket[&quot;ticket_id&quot;])<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>\u7edf\u8ba1\u6709\u6548\u7968\u5f20\u6570<\/strong><\/p>\n<\/p>\n<p><p>\u6700\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u8ba1\u7b97\u96c6\u5408\u7684\u5927\u5c0f\u6765\u83b7\u53d6\u6709\u6548\u7968\u5f20\u6570\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">valid_ticket_count = len(valid_tickets)<\/p>\n<p>print(f&quot;\u6709\u6548\u7968\u5f20\u6570: {valid_ticket_count}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u8fd9\u79cd\u65b9\u6cd5\uff0c\u6211\u4eec\u53ef\u4ee5\u9ad8\u6548\u5730\u7edf\u8ba1\u6709\u6548\u7968\u5f20\u6570\uff0c\u540c\u65f6\u786e\u4fdd\u6bcf\u4e2a\u6709\u6548\u7968\u636e\u53ea\u7edf\u8ba1\u4e00\u6b21\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u4f7f\u7528\u8fc7\u6ee4\u51fd\u6570<\/h3>\n<\/p>\n<p><p>Python\u63d0\u4f9b\u4e86\u4e00\u4e9b\u5185\u7f6e\u51fd\u6570\uff0c\u5982<code>filter<\/code>\uff0c\u53ef\u4ee5\u7528\u6765\u8fc7\u6ee4\u5217\u8868\u4e2d\u7684\u5143\u7d20\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528<code>filter<\/code>\u51fd\u6570\u6765\u8fc7\u6ee4\u51fa\u6709\u6548\u7968\u636e\uff0c\u5e76\u7edf\u8ba1\u5176\u6570\u91cf\u3002<\/p>\n<\/p>\n<p><p><strong>\u5b9a\u4e49\u7968\u636e\u6570\u636e<\/strong><\/p>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u6211\u4eec\u5b9a\u4e49\u4e00\u4e2a\u5305\u542b\u6240\u6709\u7968\u636e\u7f16\u53f7\u53ca\u5176\u6709\u6548\u6027\u72b6\u6001\u7684\u5217\u8868\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">tickets = [<\/p>\n<p>    {&quot;ticket_id&quot;: 1, &quot;valid&quot;: True},<\/p>\n<p>    {&quot;ticket_id&quot;: 2, &quot;valid&quot;: False},<\/p>\n<p>    {&quot;ticket_id&quot;: 3, &quot;valid&quot;: True},<\/p>\n<p>    {&quot;ticket_id&quot;: 4, &quot;valid&quot;: True},<\/p>\n<p>    {&quot;ticket_id&quot;: 5, &quot;valid&quot;: False}<\/p>\n<p>]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>\u4f7f\u7528\u8fc7\u6ee4\u51fd\u6570\u8fc7\u6ee4\u6709\u6548\u7968\u636e<\/strong><\/p>\n<\/p>\n<p><p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u4f7f\u7528<code>filter<\/code>\u51fd\u6570\u6765\u8fc7\u6ee4\u51fa\u6709\u6548\u7968\u636e\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">valid_tickets = list(filter(lambda ticket: ticket[&quot;valid&quot;], tickets))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>\u7edf\u8ba1\u6709\u6548\u7968\u5f20\u6570<\/strong><\/p>\n<\/p>\n<p><p>\u6700\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u8ba1\u7b97\u8fc7\u6ee4\u540e\u7684\u5217\u8868\u7684\u957f\u5ea6\u6765\u83b7\u53d6\u6709\u6548\u7968\u5f20\u6570\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">valid_ticket_count = len(valid_tickets)<\/p>\n<p>print(f&quot;\u6709\u6548\u7968\u5f20\u6570: {valid_ticket_count}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u79cd\u65b9\u6cd5\u7b80\u6d01\u660e\u4e86\uff0c\u9002\u5408\u5904\u7406\u8f83\u5c0f\u89c4\u6a21\u7684\u6570\u636e\u96c6\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u4f7f\u7528\u5217\u8868\u63a8\u5bfc\u5f0f<\/h3>\n<\/p>\n<p><p>\u5217\u8868\u63a8\u5bfc\u5f0f\u662fPython\u4e2d\u4e00\u79cd\u7b80\u6d01\u4e14\u9ad8\u6548\u7684\u521b\u5efa\u5217\u8868\u7684\u65b9\u6cd5\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u5217\u8868\u63a8\u5bfc\u5f0f\u6765\u8fc7\u6ee4\u51fa\u6709\u6548\u7968\u636e\uff0c\u5e76\u7edf\u8ba1\u5176\u6570\u91cf\u3002<\/p>\n<\/p>\n<p><p><strong>\u5b9a\u4e49\u7968\u636e\u6570\u636e<\/strong><\/p>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u6211\u4eec\u5b9a\u4e49\u4e00\u4e2a\u5305\u542b\u6240\u6709\u7968\u636e\u7f16\u53f7\u53ca\u5176\u6709\u6548\u6027\u72b6\u6001\u7684\u5217\u8868\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">tickets = [<\/p>\n<p>    {&quot;ticket_id&quot;: 1, &quot;valid&quot;: True},<\/p>\n<p>    {&quot;ticket_id&quot;: 2, &quot;valid&quot;: False},<\/p>\n<p>    {&quot;ticket_id&quot;: 3, &quot;valid&quot;: True},<\/p>\n<p>    {&quot;ticket_id&quot;: 4, &quot;valid&quot;: True},<\/p>\n<p>    {&quot;ticket_id&quot;: 5, &quot;valid&quot;: False}<\/p>\n<p>]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>\u4f7f\u7528\u5217\u8868\u63a8\u5bfc\u5f0f\u8fc7\u6ee4\u6709\u6548\u7968\u636e<\/strong><\/p>\n<\/p>\n<p><p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u4f7f\u7528\u5217\u8868\u63a8\u5bfc\u5f0f\u6765\u8fc7\u6ee4\u51fa\u6709\u6548\u7968\u636e\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">valid_tickets = [ticket for ticket in tickets if ticket[&quot;valid&quot;]]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>\u7edf\u8ba1\u6709\u6548\u7968\u5f20\u6570<\/strong><\/p>\n<\/p>\n<p><p>\u6700\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u8ba1\u7b97\u8fc7\u6ee4\u540e\u7684\u5217\u8868\u7684\u957f\u5ea6\u6765\u83b7\u53d6\u6709\u6548\u7968\u5f20\u6570\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">valid_ticket_count = len(valid_tickets)<\/p>\n<p>print(f&quot;\u6709\u6548\u7968\u5f20\u6570: {valid_ticket_count}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5217\u8868\u63a8\u5bfc\u5f0f\u7b80\u6d01\u4e14\u9ad8\u6548\uff0c\u9002\u5408\u7528\u4e8e\u5904\u7406\u8f83\u5c0f\u89c4\u6a21\u7684\u6570\u636e\u96c6\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001\u7ed3\u5408Pandas\u8fdb\u884c\u7edf\u8ba1<\/h3>\n<\/p>\n<p><p>Pandas\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u6570\u636e\u5206\u6790\u5e93\uff0c\u9002\u5408\u7528\u4e8e\u5904\u7406\u548c\u5206\u6790\u5927\u578b\u6570\u636e\u96c6\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528Pandas\u6765\u7edf\u8ba1\u6709\u6548\u7968\u5f20\u6570\u3002<\/p>\n<\/p>\n<p><p><strong>\u5bfc\u5165Pandas\u5e93\u5e76\u5b9a\u4e49\u7968\u636e\u6570\u636e<\/strong><\/p>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u5bfc\u5165Pandas\u5e93\uff0c\u5e76\u5b9a\u4e49\u4e00\u4e2a\u5305\u542b\u6240\u6709\u7968\u636e\u7f16\u53f7\u53ca\u5176\u6709\u6548\u6027\u72b6\u6001\u7684DataFrame\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<p>tickets = pd.DataFrame([<\/p>\n<p>    {&quot;ticket_id&quot;: 1, &quot;valid&quot;: True},<\/p>\n<p>    {&quot;ticket_id&quot;: 2, &quot;valid&quot;: False},<\/p>\n<p>    {&quot;ticket_id&quot;: 3, &quot;valid&quot;: True},<\/p>\n<p>    {&quot;ticket_id&quot;: 4, &quot;valid&quot;: True},<\/p>\n<p>    {&quot;ticket_id&quot;: 5, &quot;valid&quot;: False}<\/p>\n<p>])<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>\u7edf\u8ba1\u6709\u6548\u7968\u5f20\u6570<\/strong><\/p>\n<\/p>\n<p><p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528Pandas\u7684\u5185\u7f6e\u51fd\u6570\u6765\u7edf\u8ba1\u6709\u6548\u7968\u5f20\u6570\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">valid_ticket_count = tickets[&quot;valid&quot;].sum()<\/p>\n<p>print(f&quot;\u6709\u6548\u7968\u5f20\u6570: {valid_ticket_count}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>Pandas\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u51fd\u6570\u5e93\uff0c\u9002\u5408\u7528\u4e8e\u5904\u7406\u548c\u5206\u6790\u5927\u578b\u6570\u636e\u96c6\u3002\u901a\u8fc7\u4f7f\u7528Pandas\uff0c\u6211\u4eec\u53ef\u4ee5\u5feb\u901f\u7edf\u8ba1\u6709\u6548\u7968\u5f20\u6570\uff0c\u5e76\u8fdb\u884c\u66f4\u590d\u6742\u7684\u6570\u636e\u5206\u6790\u3002<\/p>\n<\/p>\n<p><h3>\u516d\u3001\u7ed3\u5408NumPy\u8fdb\u884c\u7edf\u8ba1<\/h3>\n<\/p>\n<p><p>NumPy\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u6570\u503c\u8ba1\u7b97\u5e93\uff0c\u9002\u5408\u7528\u4e8e\u5904\u7406\u548c\u5206\u6790\u5927\u578b\u6570\u503c\u6570\u636e\u96c6\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528NumPy\u6765\u7edf\u8ba1\u6709\u6548\u7968\u5f20\u6570\u3002<\/p>\n<\/p>\n<p><p><strong>\u5bfc\u5165NumPy\u5e93\u5e76\u5b9a\u4e49\u7968\u636e\u6570\u636e<\/strong><\/p>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u5bfc\u5165NumPy\u5e93\uff0c\u5e76\u5b9a\u4e49\u4e00\u4e2a\u5305\u542b\u6240\u6709\u7968\u636e\u7f16\u53f7\u53ca\u5176\u6709\u6548\u6027\u72b6\u6001\u7684\u6570\u7ec4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<p>tickets = np.array([<\/p>\n<p>    {&quot;ticket_id&quot;: 1, &quot;valid&quot;: True},<\/p>\n<p>    {&quot;ticket_id&quot;: 2, &quot;valid&quot;: False},<\/p>\n<p>    {&quot;ticket_id&quot;: 3, &quot;valid&quot;: True},<\/p>\n<p>    {&quot;ticket_id&quot;: 4, &quot;valid&quot;: True},<\/p>\n<p>    {&quot;ticket_id&quot;: 5, &quot;valid&quot;: False}<\/p>\n<p>], dtype=[(&#39;ticket_id&#39;, &#39;i4&#39;), (&#39;valid&#39;, &#39;b&#39;)])<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>\u7edf\u8ba1\u6709\u6548\u7968\u5f20\u6570<\/strong><\/p>\n<\/p>\n<p><p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528NumPy\u7684\u5185\u7f6e\u51fd\u6570\u6765\u7edf\u8ba1\u6709\u6548\u7968\u5f20\u6570\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">valid_ticket_count = np.sum(tickets[&#39;valid&#39;])<\/p>\n<p>print(f&quot;\u6709\u6548\u7968\u5f20\u6570: {valid_ticket_count}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>NumPy\u63d0\u4f9b\u4e86\u9ad8\u6548\u7684\u6570\u503c\u8ba1\u7b97\u529f\u80fd\uff0c\u9002\u5408\u7528\u4e8e\u5904\u7406\u548c\u5206\u6790\u5927\u578b\u6570\u503c\u6570\u636e\u96c6\u3002\u901a\u8fc7\u4f7f\u7528NumPy\uff0c\u6211\u4eec\u53ef\u4ee5\u5feb\u901f\u7edf\u8ba1\u6709\u6548\u7968\u5f20\u6570\uff0c\u5e76\u8fdb\u884c\u66f4\u590d\u6742\u7684\u6570\u503c\u8ba1\u7b97\u3002<\/p>\n<\/p>\n<p><h3>\u4e03\u3001\u4f7f\u7528\u81ea\u5b9a\u4e49\u51fd\u6570\u8fdb\u884c\u7edf\u8ba1<\/h3>\n<\/p>\n<p><p>\u6211\u4eec\u8fd8\u53ef\u4ee5\u7f16\u5199\u4e00\u4e2a\u81ea\u5b9a\u4e49\u51fd\u6570\u6765\u7edf\u8ba1\u6709\u6548\u7968\u5f20\u6570\u3002\u8fd9\u79cd\u65b9\u6cd5\u7075\u6d3b\u4e14\u6613\u4e8e\u6269\u5c55\uff0c\u9002\u5408\u7528\u4e8e\u5904\u7406\u4e0d\u540c\u7c7b\u578b\u7684\u6570\u636e\u3002<\/p>\n<\/p>\n<p><p><strong>\u5b9a\u4e49\u7968\u636e\u6570\u636e<\/strong><\/p>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u6211\u4eec\u5b9a\u4e49\u4e00\u4e2a\u5305\u542b\u6240\u6709\u7968\u636e\u7f16\u53f7\u53ca\u5176\u6709\u6548\u6027\u72b6\u6001\u7684\u5217\u8868\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">tickets = [<\/p>\n<p>    {&quot;ticket_id&quot;: 1, &quot;valid&quot;: True},<\/p>\n<p>    {&quot;ticket_id&quot;: 2, &quot;valid&quot;: False},<\/p>\n<p>    {&quot;ticket_id&quot;: 3, &quot;valid&quot;: True},<\/p>\n<p>    {&quot;ticket_id&quot;: 4, &quot;valid&quot;: True},<\/p>\n<p>    {&quot;ticket_id&quot;: 5, &quot;valid&quot;: False}<\/p>\n<p>]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>\u5b9a\u4e49\u81ea\u5b9a\u4e49\u51fd\u6570<\/strong><\/p>\n<\/p>\n<p><p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5b9a\u4e49\u4e00\u4e2a\u81ea\u5b9a\u4e49\u51fd\u6570\u6765\u7edf\u8ba1\u6709\u6548\u7968\u5f20\u6570\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def count_valid_tickets(tickets):<\/p>\n<p>    count = 0<\/p>\n<p>    for ticket in tickets:<\/p>\n<p>        if ticket[&quot;valid&quot;]:<\/p>\n<p>            count += 1<\/p>\n<p>    return count<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>\u8c03\u7528\u81ea\u5b9a\u4e49\u51fd\u6570<\/strong><\/p>\n<\/p>\n<p><p>\u6700\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u8c03\u7528\u81ea\u5b9a\u4e49\u51fd\u6570\u6765\u7edf\u8ba1\u6709\u6548\u7968\u5f20\u6570\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">valid_ticket_count = count_valid_tickets(tickets)<\/p>\n<p>print(f&quot;\u6709\u6548\u7968\u5f20\u6570: {valid_ticket_count}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u5b9a\u4e49\u81ea\u5b9a\u4e49\u51fd\u6570\uff0c\u6211\u4eec\u53ef\u4ee5\u7075\u6d3b\u5730\u5904\u7406\u4e0d\u540c\u7c7b\u578b\u7684\u6570\u636e\uff0c\u5e76\u8f7b\u677e\u6269\u5c55\u7edf\u8ba1\u529f\u80fd\u3002<\/p>\n<\/p>\n<p><h3>\u516b\u3001\u4f7f\u7528\u9012\u5f52\u65b9\u6cd5\u8fdb\u884c\u7edf\u8ba1<\/h3>\n<\/p>\n<p><p>\u9012\u5f52\u662f\u4e00\u79cd\u5f3a\u5927\u7684\u7f16\u7a0b\u6280\u672f\uff0c\u9002\u5408\u7528\u4e8e\u5904\u7406\u5177\u6709\u9012\u5f52\u7ed3\u6784\u7684\u6570\u636e\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u9012\u5f52\u65b9\u6cd5\u6765\u7edf\u8ba1\u6709\u6548\u7968\u5f20\u6570\u3002<\/p>\n<\/p>\n<p><p><strong>\u5b9a\u4e49\u7968\u636e\u6570\u636e<\/strong><\/p>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u6211\u4eec\u5b9a\u4e49\u4e00\u4e2a\u5305\u542b\u6240\u6709\u7968\u636e\u7f16\u53f7\u53ca\u5176\u6709\u6548\u6027\u72b6\u6001\u7684\u5217\u8868\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">tickets = [<\/p>\n<p>    {&quot;ticket_id&quot;: 1, &quot;valid&quot;: True},<\/p>\n<p>    {&quot;ticket_id&quot;: 2, &quot;valid&quot;: False},<\/p>\n<p>    {&quot;ticket_id&quot;: 3, &quot;valid&quot;: True},<\/p>\n<p>    {&quot;ticket_id&quot;: 4, &quot;valid&quot;: True},<\/p>\n<p>    {&quot;ticket_id&quot;: 5, &quot;valid&quot;: False}<\/p>\n<p>]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>\u5b9a\u4e49\u9012\u5f52\u51fd\u6570<\/strong><\/p>\n<\/p>\n<p><p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5b9a\u4e49\u4e00\u4e2a\u9012\u5f52\u51fd\u6570\u6765\u7edf\u8ba1\u6709\u6548\u7968\u5f20\u6570\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def count_valid_tickets_recursive(tickets):<\/p>\n<p>    if not tickets:<\/p>\n<p>        return 0<\/p>\n<p>    return (1 if tickets[0][&quot;valid&quot;] else 0) + count_valid_tickets_recursive(tickets[1:])<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>\u8c03\u7528\u9012\u5f52\u51fd\u6570<\/strong><\/p>\n<\/p>\n<p><p>\u6700\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u8c03\u7528\u9012\u5f52\u51fd\u6570\u6765\u7edf\u8ba1\u6709\u6548\u7968\u5f20\u6570\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">valid_ticket_count = count_valid_tickets_recursive(tickets)<\/p>\n<p>print(f&quot;\u6709\u6548\u7968\u5f20\u6570: {valid_ticket_count}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u9012\u5f52\u65b9\u6cd5\u9002\u5408\u7528\u4e8e\u5904\u7406\u5177\u6709\u9012\u5f52\u7ed3\u6784\u7684\u6570\u636e\uff0c\u4f46\u5728\u5904\u7406\u5927\u89c4\u6a21\u6570\u636e\u65f6\u53ef\u80fd\u4f1a\u5bfc\u81f4\u6808\u6ea2\u51fa\u95ee\u9898\u3002<\/p>\n<\/p>\n<p><h3>\u4e5d\u3001\u4f7f\u7528\u751f\u6210\u5668\u51fd\u6570\u8fdb\u884c\u7edf\u8ba1<\/h3>\n<\/p>\n<p><p>\u751f\u6210\u5668\u51fd\u6570\u662f\u4e00\u79cd\u9ad8\u6548\u7684\u8fed\u4ee3\u65b9\u6cd5\uff0c\u9002\u5408\u7528\u4e8e\u5904\u7406\u5927\u89c4\u6a21\u6570\u636e\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u751f\u6210\u5668\u51fd\u6570\u6765\u7edf\u8ba1\u6709\u6548\u7968\u5f20\u6570\u3002<\/p>\n<\/p>\n<p><p><strong>\u5b9a\u4e49\u7968\u636e\u6570\u636e<\/strong><\/p>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u6211\u4eec\u5b9a\u4e49\u4e00\u4e2a\u5305\u542b\u6240\u6709\u7968\u636e\u7f16\u53f7\u53ca\u5176\u6709\u6548\u6027\u72b6\u6001\u7684\u5217\u8868\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">tickets = [<\/p>\n<p>    {&quot;ticket_id&quot;: 1, &quot;valid&quot;: True},<\/p>\n<p>    {&quot;ticket_id&quot;: 2, &quot;valid&quot;: False},<\/p>\n<p>    {&quot;ticket_id&quot;: 3, &quot;valid&quot;: True},<\/p>\n<p>    {&quot;ticket_id&quot;: 4, &quot;valid&quot;: True},<\/p>\n<p>    {&quot;ticket_id&quot;: 5, &quot;valid&quot;: False}<\/p>\n<p>]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>\u5b9a\u4e49\u751f\u6210\u5668\u51fd\u6570<\/strong><\/p>\n<\/p>\n<p><p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5b9a\u4e49\u4e00\u4e2a\u751f\u6210\u5668\u51fd\u6570\u6765\u7edf\u8ba1\u6709\u6548\u7968\u5f20\u6570\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def valid_ticket_generator(tickets):<\/p>\n<p>    for ticket in tickets:<\/p>\n<p>        if ticket[&quot;valid&quot;]:<\/p>\n<p>            yield ticket<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>\u7edf\u8ba1\u6709\u6548\u7968\u5f20\u6570<\/strong><\/p>\n<\/p>\n<p><p>\u6700\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u751f\u6210\u5668\u51fd\u6570\u6765\u7edf\u8ba1\u6709\u6548\u7968\u5f20\u6570\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">valid_ticket_count = sum(1 for _ in valid_ticket_generator(tickets))<\/p>\n<p>print(f&quot;\u6709\u6548\u7968\u5f20\u6570: {valid_ticket_count}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u751f\u6210\u5668\u51fd\u6570\u9ad8\u6548\u4e14\u7075\u6d3b\uff0c\u9002\u5408\u7528\u4e8e\u5904\u7406\u5927\u89c4\u6a21\u6570\u636e\u3002<\/p>\n<\/p>\n<p><h3>\u5341\u3001\u4f7f\u7528\u591a\u7ebf\u7a0b\u8fdb\u884c\u7edf\u8ba1<\/h3>\n<\/p>\n<p><p>\u5728\u5904\u7406\u5927\u89c4\u6a21\u6570\u636e\u65f6\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u591a\u7ebf\u7a0b\u6765\u63d0\u9ad8\u7edf\u8ba1\u6548\u7387\u3002Python\u7684<code>threading<\/code>\u6a21\u5757\u63d0\u4f9b\u4e86\u591a\u7ebf\u7a0b\u652f\u6301\u3002<\/p>\n<\/p>\n<p><p><strong>\u5b9a\u4e49\u7968\u636e\u6570\u636e<\/strong><\/p>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u6211\u4eec\u5b9a\u4e49\u4e00\u4e2a\u5305\u542b\u6240\u6709\u7968\u636e\u7f16\u53f7\u53ca\u5176\u6709\u6548\u6027\u72b6\u6001\u7684\u5217\u8868\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">tickets = [<\/p>\n<p>    {&quot;ticket_id&quot;: 1, &quot;valid&quot;: True},<\/p>\n<p>    {&quot;ticket_id&quot;: 2, &quot;valid&quot;: False},<\/p>\n<p>    {&quot;ticket_id&quot;: 3, &quot;valid&quot;: True},<\/p>\n<p>    {&quot;ticket_id&quot;: 4, &quot;valid&quot;: True},<\/p>\n<p>    {&quot;ticket_id&quot;: 5, &quot;valid&quot;: False}<\/p>\n<p>]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>\u5b9a\u4e49\u591a\u7ebf\u7a0b\u7edf\u8ba1\u51fd\u6570<\/strong><\/p>\n<\/p>\n<p><p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5b9a\u4e49\u4e00\u4e2a\u591a\u7ebf\u7a0b\u7edf\u8ba1\u51fd\u6570\u6765\u7edf\u8ba1\u6709\u6548\u7968\u5f20\u6570\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import threading<\/p>\n<p>valid_ticket_count = 0<\/p>\n<p>count_lock = threading.Lock()<\/p>\n<p>def count_valid_tickets_thread(tickets):<\/p>\n<p>    global valid_ticket_count<\/p>\n<p>    count = sum(1 for ticket in tickets if ticket[&quot;valid&quot;])<\/p>\n<p>    with count_lock:<\/p>\n<p>        valid_ticket_count += count<\/p>\n<p>threads = []<\/p>\n<p>chunk_size = len(tickets) \/\/ 4<\/p>\n<p>for i in range(0, len(tickets), chunk_size):<\/p>\n<p>    thread = threading.Thread(target=count_valid_tickets_thread, args=(tickets[i:i + chunk_size],))<\/p>\n<p>    threads.append(thread)<\/p>\n<p>    thread.start()<\/p>\n<p>for thread in threads:<\/p>\n<p>    thread.join()<\/p>\n<p>print(f&quot;\u6709\u6548\u7968\u5f20\u6570: {valid_ticket_count}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u591a\u7ebf\u7a0b\u65b9\u6cd5\u53ef\u4ee5\u663e\u8457\u63d0\u9ad8\u7edf\u8ba1\u6548\u7387\uff0c\u9002\u5408\u7528\u4e8e\u5904\u7406\u5927\u89c4\u6a21\u6570\u636e\u3002<\/p>\n<\/p>\n<p><h3>\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u5728Python\u4e2d\u7edf\u8ba1\u6709\u6548\u7968\u5f20\u6570\u6709\u591a\u79cd\u65b9\u6cd5\uff0c\u5305\u62ec\u4f7f\u7528\u5b57\u5178\u3001\u96c6\u5408\u3001\u8fc7\u6ee4\u51fd\u6570\u3001\u5217\u8868\u63a8\u5bfc\u5f0f\u3001Pandas\u3001NumPy\u3001\u81ea\u5b9a\u4e49\u51fd\u6570\u3001\u9012\u5f52\u65b9\u6cd5\u3001\u751f\u6210\u5668\u51fd\u6570\u548c\u591a\u7ebf\u7a0b\u65b9\u6cd5\u3002\u6bcf\u79cd\u65b9\u6cd5\u90fd\u6709\u5176\u4f18\u70b9\u548c\u9002\u7528\u573a\u666f\u3002\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\u53ef\u4ee5\u6839\u636e\u6570\u636e\u89c4\u6a21\u3001\u6570\u636e\u7ed3\u6784\u548c\u5177\u4f53\u9700\u6c42\u6765\u51b3\u5b9a\u3002\u5e0c\u671b\u901a\u8fc7\u672c\u6587\u7684\u4ecb\u7ecd\uff0c\u60a8\u80fd\u591f\u638c\u63e1\u591a\u79cd\u7edf\u8ba1\u6709\u6548\u7968\u5f20\u6570\u7684\u65b9\u6cd5\uff0c\u5e76\u6839\u636e\u5177\u4f53\u60c5\u51b5\u9009\u62e9\u6700\u5408\u9002\u7684\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u8bfb\u53d6\u548c\u5904\u7406\u6295\u7968\u6570\u636e\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528Pandas\u5e93\u6765\u8bfb\u53d6\u548c\u5904\u7406\u6295\u7968\u6570\u636e\u3002\u901a\u8fc7\u8bfb\u53d6CSV\u6216Excel\u6587\u4ef6\uff0c\u4f7f\u7528DataFrame\u5bf9\u8c61\u6765\u5b58\u50a8\u6570\u636e\uff0c\u53ef\u4ee5\u8f7b\u677e\u5730\u5bf9\u5404\u4e2a\u7968\u5f20\u8fdb\u884c\u7edf\u8ba1\u3002\u5229\u7528Pandas\u7684\u5404\u79cd\u65b9\u6cd5\uff0c\u4f8b\u5982<code>groupby<\/code>\u548c<code>count<\/code>\uff0c\u53ef\u4ee5\u5feb\u901f\u8ba1\u7b97\u6709\u6548\u7968\u5f20\u6570\u3002<\/p>\n<p><strong>\u600e\u6837\u5b9a\u4e49\u6709\u6548\u7968\u5f20\uff1f<\/strong><br \/>\u6709\u6548\u7968\u5f20\u901a\u5e38\u662f\u6307\u7b26\u5408\u89c4\u5b9a\u7684\u3001\u672a\u88ab\u7be1\u6539\u7684\u6295\u7968\u3002\u5728\u5177\u4f53\u7684\u5b9e\u73b0\u4e2d\uff0c\u53ef\u4ee5\u6839\u636e\u6295\u7968\u7684\u683c\u5f0f\u548c\u89c4\u5219\u8bbe\u5b9a\u6761\u4ef6\uff0c\u4f8b\u5982\u68c0\u67e5\u662f\u5426\u586b\u5199\u5b8c\u6574\u3001\u662f\u5426\u5728\u89c4\u5b9a\u7684\u65f6\u95f4\u5185\u6295\u9012\u7b49\u3002\u786e\u4fdd\u5728\u7edf\u8ba1\u524d\uff0c\u660e\u786e\u6709\u6548\u7968\u5f20\u7684\u6807\u51c6\uff0c\u4ee5\u4fbf\u51c6\u786e\u8ba1\u7b97\u3002<\/p>\n<p><strong>\u6709\u6ca1\u6709\u73b0\u6210\u7684Python\u5e93\u53ef\u4ee5\u5e2e\u52a9\u8fdb\u884c\u6295\u7968\u7edf\u8ba1\uff1f<\/strong><br \/>\u662f\u7684\uff0c\u9664\u4e86Pandas\u5916\uff0c\u8fd8\u6709\u4e00\u4e9b\u4e13\u95e8\u7528\u4e8e\u6295\u7968\u7edf\u8ba1\u7684Python\u5e93\uff0c\u5982<code>Vote<\/code>\u548c<code>election.py<\/code>\u3002\u8fd9\u4e9b\u5e93\u63d0\u4f9b\u4e86\u5c01\u88c5\u597d\u7684\u51fd\u6570\u548c\u65b9\u6cd5\uff0c\u80fd\u591f\u5904\u7406\u6295\u7968\u6570\u636e\u7684\u8f93\u5165\u3001\u6709\u6548\u6027\u68c0\u67e5\u53ca\u7ed3\u679c\u7edf\u8ba1\uff0c\u5927\u5927\u7b80\u5316\u4e86\u5f00\u53d1\u8fc7\u7a0b\u3002<\/p>\n<p><strong>\u5982\u4f55\u5904\u7406\u65e0\u6548\u7968\u5f20\uff0c\u4ee5\u514d\u5f71\u54cd\u7edf\u8ba1\u7ed3\u679c\uff1f<\/strong><br \/>\u5728\u7edf\u8ba1\u6709\u6548\u7968\u5f20\u4e4b\u524d\uff0c\u9700\u5148\u5bf9\u6570\u636e\u8fdb\u884c\u6e05\u6d17\u3002\u53ef\u4ee5\u7f16\u5199\u903b\u8f91\u6765\u7b5b\u9009\u51fa\u65e0\u6548\u7968\u5f20\uff0c\u4f8b\u5982\u53bb\u9664\u91cd\u590d\u7684\u6295\u7968\u3001\u68c0\u67e5\u683c\u5f0f\u9519\u8bef\u7684\u8f93\u5165\u7b49\u3002\u901a\u8fc7\u6761\u4ef6\u8fc7\u6ee4\uff0c\u53ef\u4ee5\u786e\u4fdd\u6700\u7ec8\u7edf\u8ba1\u7ed3\u679c\u7684\u51c6\u786e\u6027\u548c\u6709\u6548\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u7edf\u8ba1\u6709\u6548\u7968\u5f20\u6570 \u5728Python\u4e2d\u7edf\u8ba1\u6709\u6548\u7968\u5f20\u6570\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u65b9\u6cd5\u5b9e\u73b0\u3002\u4f7f\u7528\u96c6\u5408\u6216\u5b57\u5178\u3001\u904d\u5386\u6570\u636e\u3001\u8fc7\u6ee4\u65e0\u6548\u7968\u5f20\u90fd\u662f [&hellip;]","protected":false},"author":3,"featured_media":1077324,"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\/1077315"}],"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=1077315"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1077315\/revisions"}],"predecessor-version":[{"id":1077326,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1077315\/revisions\/1077326"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1077324"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1077315"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1077315"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1077315"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}