{"id":1181733,"date":"2025-01-15T18:55:19","date_gmt":"2025-01-15T10:55:19","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1181733.html"},"modified":"2025-01-15T18:55:22","modified_gmt":"2025-01-15T10:55:22","slug":"python%e5%a6%82%e4%bd%95%e5%af%bc%e5%85%a5%e6%a8%a1%e5%9d%97%e5%81%9a%e6%b8%b8%e6%88%8f","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1181733.html","title":{"rendered":"python\u5982\u4f55\u5bfc\u5165\u6a21\u5757\u505a\u6e38\u620f"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25125942\/6968a8d7-1ccc-4727-9c83-a9294a2d0286.webp\" alt=\"python\u5982\u4f55\u5bfc\u5165\u6a21\u5757\u505a\u6e38\u620f\" \/><\/p>\n<p><p> <strong>\u5728Python\u4e2d\u5bfc\u5165\u6a21\u5757\u505a\u6e38\u620f\uff0c\u53ef\u4ee5\u4f7f\u7528\u6807\u51c6\u5e93\u548c\u7b2c\u4e09\u65b9\u5e93\uff0c\u5982pygame\u3001Pygame Zero\u7b49\u3002Python\u63d0\u4f9b\u4e86\u975e\u5e38\u4fbf\u6377\u7684\u6a21\u5757\u5bfc\u5165\u65b9\u5f0f\uff0c\u4f7f\u7528import\u8bed\u53e5\u5373\u53ef\u5b8c\u6210\u3002<\/strong><\/p>\n<\/p>\n<p><p><strong>\u5176\u4e2d\uff0cpygame\u662f\u4e00\u4e2a\u975e\u5e38\u6d41\u884c\u7684\u7b2c\u4e09\u65b9\u5e93\uff0c\u4e13\u95e8\u7528\u4e8e\u5236\u4f5c2D\u6e38\u620f\u3002\u5b83\u63d0\u4f9b\u4e86\u56fe\u5f62\u3001\u58f0\u97f3\u3001\u8f93\u5165\u7b49\u591a\u79cd\u529f\u80fd\uff0c\u9002\u5408\u521d\u5b66\u8005\u548c\u4e13\u4e1a\u6e38\u620f\u5f00\u53d1\u8005\u3002<\/strong><\/p>\n<\/p>\n<p><p><strong>\u9996\u5148\uff0c\u4f60\u9700\u8981\u5b89\u88c5pygame\u5e93\uff0c\u53ef\u4ee5\u901a\u8fc7pip\u547d\u4ee4\u8fdb\u884c\u5b89\u88c5\uff1a<\/strong><\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install pygame<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>\u63a5\u4e0b\u6765\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff0c\u5c55\u793a\u5982\u4f55\u4f7f\u7528pygame\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u6e38\u620f\u7a97\u53e3\uff1a<\/strong><\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pygame<\/p>\n<h2><strong>\u521d\u59cb\u5316 Pygame<\/strong><\/h2>\n<p>pygame.init()<\/p>\n<h2><strong>\u8bbe\u7f6e\u5c4f\u5e55\u5927\u5c0f<\/strong><\/h2>\n<p>screen = pygame.display.set_mode((800, 600))<\/p>\n<h2><strong>\u8bbe\u7f6e\u7a97\u53e3\u6807\u9898<\/strong><\/h2>\n<p>pygame.display.set_caption(&quot;My Game&quot;)<\/p>\n<h2><strong>\u4e3b\u5faa\u73af<\/strong><\/h2>\n<p>running = True<\/p>\n<p>while running:<\/p>\n<p>    for event in pygame.event.get():<\/p>\n<p>        if event.type == pygame.QUIT:<\/p>\n<p>            running = False<\/p>\n<h2><strong>\u9000\u51fa Pygame<\/strong><\/h2>\n<p>pygame.quit()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u9996\u5148\u5bfc\u5165\u4e86pygame\u6a21\u5757\uff0c\u7136\u540e\u521d\u59cb\u5316\u5b83\uff0c\u63a5\u7740\u521b\u5efa\u4e86\u4e00\u4e2a800&#215;600\u50cf\u7d20\u7684\u7a97\u53e3\uff0c\u5e76\u8bbe\u7f6e\u4e86\u7a97\u53e3\u7684\u6807\u9898\u3002\u5728\u4e3b\u5faa\u73af\u4e2d\uff0c\u6211\u4eec\u76d1\u542c\u4e86\u9000\u51fa\u4e8b\u4ef6\uff08\u70b9\u51fb\u5173\u95ed\u6309\u94ae\uff09\uff0c\u5982\u679c\u68c0\u6d4b\u5230\u9000\u51fa\u4e8b\u4ef6\uff0c\u5219\u9000\u51fa\u4e3b\u5faa\u73af\u5e76\u5173\u95ed\u7a97\u53e3\u3002<\/p>\n<\/p>\n<p><p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528pygame\u6a21\u5757\u5236\u4f5c\u4e00\u4e2a\u5b8c\u6574\u7684\u6e38\u620f\uff0c\u5305\u62ec\u56fe\u5f62\u7ed8\u5236\u3001\u4e8b\u4ef6\u5904\u7406\u3001\u6e38\u620f\u903b\u8f91\u7b49\u65b9\u9762\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u521d\u59cb\u5316\u548c\u8bbe\u7f6e<\/h3>\n<\/p>\n<p><h4>1. \u521d\u59cb\u5316 Pygame<\/h4>\n<\/p>\n<p><p>\u5728\u4f7f\u7528Pygame\u4e4b\u524d\uff0c\u9996\u5148\u9700\u8981\u521d\u59cb\u5316\u5b83\u3002\u521d\u59cb\u5316\u7684\u6b65\u9aa4\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u8981\u4e00\u884c\u4ee3\u7801\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">pygame.init()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u884c\u4ee3\u7801\u4f1a\u521d\u59cb\u5316\u6240\u6709\u9700\u8981\u7684Pygame\u6a21\u5757\uff0c\u4f7f\u5176\u53ef\u4ee5\u6b63\u5e38\u5de5\u4f5c\u3002<\/p>\n<\/p>\n<p><h4>2. \u8bbe\u7f6e\u5c4f\u5e55\u5927\u5c0f<\/h4>\n<\/p>\n<p><p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u9700\u8981\u8bbe\u7f6e\u6e38\u620f\u7a97\u53e3\u7684\u5927\u5c0f\u3002\u53ef\u4ee5\u4f7f\u7528<code>pygame.display.set_mode()<\/code>\u51fd\u6570\u6765\u5b9e\u73b0\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">screen = pygame.display.set_mode((800, 600))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u91cc\uff0c\u6211\u4eec\u5c06\u7a97\u53e3\u5927\u5c0f\u8bbe\u7f6e\u4e3a800&#215;600\u50cf\u7d20\uff0c\u5e76\u5c06\u5176\u8d4b\u503c\u7ed9\u4e00\u4e2a\u540d\u4e3a<code>screen<\/code>\u7684\u53d8\u91cf\uff0c\u4ee5\u4fbf\u540e\u7eed\u4f7f\u7528\u3002<\/p>\n<\/p>\n<p><h4>3. \u8bbe\u7f6e\u7a97\u53e3\u6807\u9898<\/h4>\n<\/p>\n<p><p>\u4e3a\u4e86\u8ba9\u6e38\u620f\u7a97\u53e3\u66f4\u5177\u8fa8\u8bc6\u5ea6\uff0c\u53ef\u4ee5\u8bbe\u7f6e\u4e00\u4e2a\u7a97\u53e3\u6807\u9898\u3002\u53ef\u4ee5\u4f7f\u7528<code>pygame.display.set_caption()<\/code>\u51fd\u6570\u6765\u5b9e\u73b0\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">pygame.display.set_caption(&quot;My Game&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u6837\uff0c\u6e38\u620f\u7a97\u53e3\u7684\u6807\u9898\u5c31\u4f1a\u663e\u793a\u4e3a&quot;My Game&quot;\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u4e8b\u4ef6\u5904\u7406<\/h3>\n<\/p>\n<p><h4>1. \u4e8b\u4ef6\u5faa\u73af<\/h4>\n<\/p>\n<p><p>\u5728\u6e38\u620f\u5f00\u53d1\u4e2d\uff0c\u4e8b\u4ef6\u5904\u7406\u662f\u4e00\u4e2a\u975e\u5e38\u91cd\u8981\u7684\u73af\u8282\u3002Pygame\u901a\u8fc7\u4e8b\u4ef6\u5faa\u73af\u6765\u5904\u7406\u7528\u6237\u7684\u8f93\u5165\u548c\u5176\u4ed6\u4e8b\u4ef6\u3002\u53ef\u4ee5\u4f7f\u7528<code>pygame.event.get()<\/code>\u51fd\u6570\u6765\u83b7\u53d6\u5f53\u524d\u6240\u6709\u7684\u4e8b\u4ef6\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">for event in pygame.event.get():<\/p>\n<p>    if event.type == pygame.QUIT:<\/p>\n<p>        running = False<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u904d\u5386\u4e86\u6240\u6709\u7684\u4e8b\u4ef6\uff0c\u5e76\u68c0\u67e5\u662f\u5426\u6709\u9000\u51fa\u4e8b\u4ef6\uff08\u70b9\u51fb\u5173\u95ed\u6309\u94ae\uff09\u3002\u5982\u679c\u68c0\u6d4b\u5230\u9000\u51fa\u4e8b\u4ef6\uff0c\u5219\u5c06<code>running<\/code>\u53d8\u91cf\u8bbe\u7f6e\u4e3a<code>False<\/code>\uff0c\u4ece\u800c\u9000\u51fa\u4e3b\u5faa\u73af\u3002<\/p>\n<\/p>\n<p><h4>2. \u952e\u76d8\u548c\u9f20\u6807\u4e8b\u4ef6<\/h4>\n<\/p>\n<p><p>\u9664\u4e86\u9000\u51fa\u4e8b\u4ef6\uff0c\u6e38\u620f\u4e2d\u8fd8\u9700\u8981\u5904\u7406\u952e\u76d8\u548c\u9f20\u6807\u4e8b\u4ef6\u3002\u53ef\u4ee5\u901a\u8fc7\u68c0\u67e5\u4e8b\u4ef6\u7c7b\u578b\u6765\u5904\u7406\u4e0d\u540c\u7684\u4e8b\u4ef6\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">for event in pygame.event.get():<\/p>\n<p>    if event.type == pygame.QUIT:<\/p>\n<p>        running = False<\/p>\n<p>    elif event.type == pygame.KEYDOWN:<\/p>\n<p>        if event.key == pygame.K_LEFT:<\/p>\n<p>            print(&quot;Left arrow key pressed&quot;)<\/p>\n<p>    elif event.type == pygame.MOUSEBUTTONDOWN:<\/p>\n<p>        if event.button == 1:<\/p>\n<p>            print(&quot;Mouse left button clicked&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u5904\u7406\u4e86\u952e\u76d8\u6309\u4e0b\u4e8b\u4ef6\u548c\u9f20\u6807\u70b9\u51fb\u4e8b\u4ef6\u3002\u5982\u679c\u6309\u4e0b\u7684\u662f\u5de6\u7bad\u5934\u952e\uff0c\u5219\u6253\u5370&quot;Left arrow key pressed&quot;\uff1b\u5982\u679c\u70b9\u51fb\u7684\u662f\u9f20\u6807\u5de6\u952e\uff0c\u5219\u6253\u5370&quot;Mouse left button clicked&quot;\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u56fe\u5f62\u7ed8\u5236<\/h3>\n<\/p>\n<p><h4>1. \u7ed8\u5236\u57fa\u672c\u56fe\u5f62<\/h4>\n<\/p>\n<p><p>Pygame\u63d0\u4f9b\u4e86\u591a\u79cd\u7ed8\u5236\u57fa\u672c\u56fe\u5f62\u7684\u51fd\u6570\uff0c\u5982\u77e9\u5f62\u3001\u5706\u5f62\u3001\u7ebf\u6761\u7b49\u3002\u53ef\u4ee5\u4f7f\u7528<code>pygame.draw<\/code>\u6a21\u5757\u6765\u5b9e\u73b0\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">pygame.draw.rect(screen, (255, 0, 0), (100, 100, 50, 50))<\/p>\n<p>pygame.draw.circle(screen, (0, 255, 0), (200, 200), 30)<\/p>\n<p>pygame.draw.line(screen, (0, 0, 255), (300, 300), (400, 400), 5)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u5206\u522b\u7ed8\u5236\u4e86\u4e00\u4e2a\u7ea2\u8272\u7684\u77e9\u5f62\u3001\u4e00\u4e2a\u7eff\u8272\u7684\u5706\u5f62\u548c\u4e00\u6761\u84dd\u8272\u7684\u7ebf\u6761\u3002<\/p>\n<\/p>\n<p><h4>2. \u663e\u793a\u56fe\u50cf<\/h4>\n<\/p>\n<p><p>\u9664\u4e86\u7ed8\u5236\u57fa\u672c\u56fe\u5f62\uff0c\u8fd8\u53ef\u4ee5\u663e\u793a\u56fe\u50cf\u3002\u53ef\u4ee5\u4f7f\u7528<code>pygame.image.load()<\/code>\u51fd\u6570\u52a0\u8f7d\u56fe\u50cf\uff0c\u5e76\u4f7f\u7528<code>blit()<\/code>\u51fd\u6570\u5c06\u5176\u7ed8\u5236\u5230\u5c4f\u5e55\u4e0a\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">image = pygame.image.load(&quot;my_image.png&quot;)<\/p>\n<p>screen.blit(image, (100, 100))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u52a0\u8f7d\u4e86\u540d\u4e3a&quot;my_image.png&quot;\u7684\u56fe\u50cf\uff0c\u5e76\u5c06\u5176\u7ed8\u5236\u5230\u5c4f\u5e55\u4e0a\u7684(100, 100)\u4f4d\u7f6e\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u6e38\u620f\u903b\u8f91<\/h3>\n<\/p>\n<p><h4>1. \u6e38\u620f\u5faa\u73af<\/h4>\n<\/p>\n<p><p>\u6e38\u620f\u903b\u8f91\u901a\u5e38\u5305\u542b\u5728\u4e00\u4e2a\u65e0\u9650\u5faa\u73af\u4e2d\uff0c\u79f0\u4e3a\u6e38\u620f\u5faa\u73af\u3002\u5728\u6bcf\u4e00\u5e27\u4e2d\uff0c\u6e38\u620f\u5faa\u73af\u4f1a\u6267\u884c\u4ee5\u4e0b\u51e0\u4e2a\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u5904\u7406\u4e8b\u4ef6<\/li>\n<li>\u66f4\u65b0\u6e38\u620f\u72b6\u6001<\/li>\n<li>\u7ed8\u5236\u56fe\u5f62<\/li>\n<li>\u5237\u65b0\u5c4f\u5e55<\/li>\n<\/ol>\n<p><p>\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u5b9e\u73b0\u4e00\u4e2a\u7b80\u5355\u7684\u6e38\u620f\u5faa\u73af\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">running = True<\/p>\n<p>while running:<\/p>\n<p>    for event in pygame.event.get():<\/p>\n<p>        if event.type == pygame.QUIT:<\/p>\n<p>            running = False<\/p>\n<p>    # \u66f4\u65b0\u6e38\u620f\u72b6\u6001<\/p>\n<p>    # \u7ed8\u5236\u56fe\u5f62<\/p>\n<p>    screen.fill((0, 0, 0))  # \u6e05\u5c4f<\/p>\n<p>    pygame.draw.rect(screen, (255, 0, 0), (100, 100, 50, 50))<\/p>\n<p>    # \u5237\u65b0\u5c4f\u5e55<\/p>\n<p>    pygame.display.flip()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u9996\u5148\u5904\u7406\u4e86\u6240\u6709\u7684\u4e8b\u4ef6\uff0c\u7136\u540e\u66f4\u65b0\u6e38\u620f\u72b6\u6001\uff0c\u63a5\u7740\u7ed8\u5236\u56fe\u5f62\uff0c\u6700\u540e\u5237\u65b0\u5c4f\u5e55\u3002<\/p>\n<\/p>\n<p><h4>2. \u66f4\u65b0\u6e38\u620f\u72b6\u6001<\/h4>\n<\/p>\n<p><p>\u6e38\u620f\u72b6\u6001\u7684\u66f4\u65b0\u901a\u5e38\u5305\u62ec\u5904\u7406\u7528\u6237\u8f93\u5165\u3001\u66f4\u65b0\u89d2\u8272\u4f4d\u7f6e\u3001\u68c0\u6d4b\u78b0\u649e\u7b49\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u66f4\u65b0\u4e00\u4e2a\u77e9\u5f62\u7684\u4f4d\u7f6e\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">rect_x = 100<\/p>\n<p>rect_y = 100<\/p>\n<p>rect_speed_x = 5<\/p>\n<p>rect_speed_y = 5<\/p>\n<p>running = True<\/p>\n<p>while running:<\/p>\n<p>    for event in pygame.event.get():<\/p>\n<p>        if event.type == pygame.QUIT:<\/p>\n<p>            running = False<\/p>\n<p>    # \u66f4\u65b0\u77e9\u5f62\u4f4d\u7f6e<\/p>\n<p>    rect_x += rect_speed_x<\/p>\n<p>    rect_y += rect_speed_y<\/p>\n<p>    # \u68c0\u6d4b\u8fb9\u754c\u78b0\u649e<\/p>\n<p>    if rect_x &lt; 0 or rect_x &gt; 750:<\/p>\n<p>        rect_speed_x = -rect_speed_x<\/p>\n<p>    if rect_y &lt; 0 or rect_y &gt; 550:<\/p>\n<p>        rect_speed_y = -rect_speed_y<\/p>\n<p>    # \u7ed8\u5236\u56fe\u5f62<\/p>\n<p>    screen.fill((0, 0, 0))  # \u6e05\u5c4f<\/p>\n<p>    pygame.draw.rect(screen, (255, 0, 0), (rect_x, rect_y, 50, 50))<\/p>\n<p>    # \u5237\u65b0\u5c4f\u5e55<\/p>\n<p>    pygame.display.flip()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u5b9a\u4e49\u4e86\u4e00\u4e2a\u77e9\u5f62\u7684\u521d\u59cb\u4f4d\u7f6e\u548c\u901f\u5ea6\uff0c\u5e76\u5728\u6bcf\u4e00\u5e27\u4e2d\u66f4\u65b0\u5b83\u7684\u4f4d\u7f6e\u3002\u5982\u679c\u77e9\u5f62\u78b0\u5230\u8fb9\u754c\uff0c\u5219\u53cd\u8f6c\u5b83\u7684\u901f\u5ea6\uff0c\u4ece\u800c\u5b9e\u73b0\u77e9\u5f62\u5728\u5c4f\u5e55\u4e0a\u7684\u53cd\u5f39\u6548\u679c\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001\u58f0\u97f3\u548c\u97f3\u4e50<\/h3>\n<\/p>\n<p><h4>1. \u64ad\u653e\u58f0\u97f3<\/h4>\n<\/p>\n<p><p>Pygame\u8fd8\u652f\u6301\u64ad\u653e\u58f0\u97f3\u548c\u97f3\u4e50\u3002\u53ef\u4ee5\u4f7f\u7528<code>pygame.mixer.Sound()<\/code>\u51fd\u6570\u52a0\u8f7d\u58f0\u97f3\u6587\u4ef6\uff0c\u5e76\u4f7f\u7528<code>play()<\/code>\u51fd\u6570\u64ad\u653e\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">sound = pygame.mixer.Sound(&quot;my_sound.wav&quot;)<\/p>\n<p>sound.play()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u52a0\u8f7d\u4e86\u540d\u4e3a&quot;my_sound.wav&quot;\u7684\u58f0\u97f3\u6587\u4ef6\uff0c\u5e76\u64ad\u653e\u5b83\u3002<\/p>\n<\/p>\n<p><h4>2. \u64ad\u653e\u97f3\u4e50<\/h4>\n<\/p>\n<p><p>\u9664\u4e86\u64ad\u653e\u58f0\u97f3\uff0c\u8fd8\u53ef\u4ee5\u64ad\u653e\u80cc\u666f\u97f3\u4e50\u3002\u53ef\u4ee5\u4f7f\u7528<code>pygame.mixer.music<\/code>\u6a21\u5757\u6765\u5b9e\u73b0\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">pygame.mixer.music.load(&quot;background_music.mp3&quot;)<\/p>\n<p>pygame.mixer.music.play(-1)  # \u5faa\u73af\u64ad\u653e<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u52a0\u8f7d\u4e86\u540d\u4e3a&quot;background_music.mp3&quot;\u7684\u97f3\u4e50\u6587\u4ef6\uff0c\u5e76\u5faa\u73af\u64ad\u653e\u5b83\u3002<\/p>\n<\/p>\n<p><h3>\u516d\u3001\u4f18\u5316\u548c\u8c03\u8bd5<\/h3>\n<\/p>\n<p><h4>1. \u5e27\u7387\u63a7\u5236<\/h4>\n<\/p>\n<p><p>\u4e3a\u4e86\u8ba9\u6e38\u620f\u8fd0\u884c\u66f4\u52a0\u6d41\u7545\uff0c\u9700\u8981\u63a7\u5236\u5e27\u7387\u3002\u53ef\u4ee5\u4f7f\u7528<code>pygame.time.Clock()<\/code>\u5bf9\u8c61\u6765\u5b9e\u73b0\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">clock = pygame.time.Clock()<\/p>\n<p>running = True<\/p>\n<p>while running:<\/p>\n<p>    for event in pygame.event.get():<\/p>\n<p>        if event.type == pygame.QUIT:<\/p>\n<p>            running = False<\/p>\n<p>    # \u66f4\u65b0\u6e38\u620f\u72b6\u6001<\/p>\n<p>    # \u7ed8\u5236\u56fe\u5f62<\/p>\n<p>    screen.fill((0, 0, 0))  # \u6e05\u5c4f<\/p>\n<p>    pygame.draw.rect(screen, (255, 0, 0), (100, 100, 50, 50))<\/p>\n<p>    # \u5237\u65b0\u5c4f\u5e55<\/p>\n<p>    pygame.display.flip()<\/p>\n<p>    # \u63a7\u5236\u5e27\u7387<\/p>\n<p>    clock.tick(60)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e00\u4e2a<code>Clock<\/code>\u5bf9\u8c61\uff0c\u5e76\u5728\u6bcf\u4e00\u5e27\u7ed3\u675f\u65f6\u8c03\u7528<code>tick(60)<\/code>\u51fd\u6570\uff0c\u5c06\u5e27\u7387\u9650\u5236\u572860\u5e27\u6bcf\u79d2\u3002<\/p>\n<\/p>\n<p><h4>2. \u8c03\u8bd5<\/h4>\n<\/p>\n<p><p>\u5728\u5f00\u53d1\u8fc7\u7a0b\u4e2d\uff0c\u8c03\u8bd5\u662f\u975e\u5e38\u91cd\u8981\u7684\u4e00\u73af\u3002\u53ef\u4ee5\u4f7f\u7528<code>print()<\/code>\u51fd\u6570\u8f93\u51fa\u53d8\u91cf\u503c\uff0c\u6216\u8005\u4f7f\u7528Pygame\u63d0\u4f9b\u7684\u8c03\u8bd5\u5de5\u5177\u8fdb\u884c\u8c03\u8bd5\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u4f7f\u7528<code>pygame.draw.rect()<\/code>\u51fd\u6570\u7ed8\u5236\u8c03\u8bd5\u4fe1\u606f\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u7ed8\u5236\u8c03\u8bd5\u4fe1\u606f<\/p>\n<p>pygame.draw.rect(screen, (255, 255, 255), (rect_x, rect_y, 50, 50), 1)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u7ed8\u5236\u4e86\u4e00\u4e2a\u767d\u8272\u7684\u77e9\u5f62\u8fb9\u6846\uff0c\u7528\u4e8e\u8c03\u8bd5\u3002<\/p>\n<\/p>\n<p><h3>\u4e03\u3001\u5b9e\u4f8b\uff1a\u5236\u4f5c\u4e00\u4e2a\u7b80\u5355\u7684\u6e38\u620f<\/h3>\n<\/p>\n<p><p>\u4e3a\u4e86\u66f4\u597d\u5730\u7406\u89e3\u5982\u4f55\u4f7f\u7528Pygame\u5236\u4f5c\u6e38\u620f\uff0c\u4e0b\u9762\u6211\u4eec\u5c06\u5236\u4f5c\u4e00\u4e2a\u7b80\u5355\u7684\u6253\u7816\u5757\u6e38\u620f\u3002<\/p>\n<\/p>\n<p><h4>1. \u521d\u59cb\u5316\u548c\u8bbe\u7f6e<\/h4>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u521d\u59cb\u5316Pygame\uff0c\u5e76\u8bbe\u7f6e\u5c4f\u5e55\u5927\u5c0f\u548c\u7a97\u53e3\u6807\u9898\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pygame<\/p>\n<p>pygame.init()<\/p>\n<p>screen = pygame.display.set_mode((800, 600))<\/p>\n<p>pygame.display.set_caption(&quot;Breakout Game&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. \u5b9a\u4e49\u6e38\u620f\u5bf9\u8c61<\/h4>\n<\/p>\n<p><p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u9700\u8981\u5b9a\u4e49\u6e38\u620f\u4e2d\u7684\u5bf9\u8c61\uff0c\u5305\u62ec\u7403\u3001\u6321\u677f\u548c\u7816\u5757\u3002\u53ef\u4ee5\u4f7f\u7528\u7c7b\u6765\u5b9a\u4e49\u8fd9\u4e9b\u5bf9\u8c61\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">class Ball:<\/p>\n<p>    def __init__(self, x, y, radius, color):<\/p>\n<p>        self.x = x<\/p>\n<p>        self.y = y<\/p>\n<p>        self.radius = radius<\/p>\n<p>        self.color = color<\/p>\n<p>        self.speed_x = 5<\/p>\n<p>        self.speed_y = 5<\/p>\n<p>    def draw(self, screen):<\/p>\n<p>        pygame.draw.circle(screen, self.color, (self.x, self.y), self.radius)<\/p>\n<p>    def move(self):<\/p>\n<p>        self.x += self.speed_x<\/p>\n<p>        self.y += self.speed_y<\/p>\n<p>class Paddle:<\/p>\n<p>    def __init__(self, x, y, width, height, color):<\/p>\n<p>        self.x = x<\/p>\n<p>        self.y = y<\/p>\n<p>        self.width = width<\/p>\n<p>        self.height = height<\/p>\n<p>        self.color = color<\/p>\n<p>        self.speed = 10<\/p>\n<p>    def draw(self, screen):<\/p>\n<p>        pygame.draw.rect(screen, self.color, (self.x, self.y, self.width, self.height))<\/p>\n<p>    def move(self, direction):<\/p>\n<p>        if direction == &quot;left&quot; and self.x &gt; 0:<\/p>\n<p>            self.x -= self.speed<\/p>\n<p>        elif direction == &quot;right&quot; and self.x &lt; 800 - self.width:<\/p>\n<p>            self.x += self.speed<\/p>\n<p>class Brick:<\/p>\n<p>    def __init__(self, x, y, width, height, color):<\/p>\n<p>        self.x = x<\/p>\n<p>        self.y = y<\/p>\n<p>        self.width = width<\/p>\n<p>        self.height = height<\/p>\n<p>        self.color = color<\/p>\n<p>        self.visible = True<\/p>\n<p>    def draw(self, screen):<\/p>\n<p>        if self.visible:<\/p>\n<p>            pygame.draw.rect(screen, self.color, (self.x, self.y, self.width, self.height))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u5b9a\u4e49\u4e86\u4e09\u4e2a\u7c7b\uff1a<code>Ball<\/code>\u3001<code>Paddle<\/code>\u548c<code>Brick<\/code>\uff0c\u5206\u522b\u8868\u793a\u7403\u3001\u6321\u677f\u548c\u7816\u5757\u3002\u6bcf\u4e2a\u7c7b\u90fd\u6709<code>draw<\/code>\u65b9\u6cd5\u7528\u4e8e\u7ed8\u5236\u5bf9\u8c61\uff0c\u4ee5\u53ca\u5176\u4ed6\u65b9\u6cd5\u7528\u4e8e\u66f4\u65b0\u5bf9\u8c61\u7684\u72b6\u6001\u3002<\/p>\n<\/p>\n<p><h4>3. \u521b\u5efa\u6e38\u620f\u5bf9\u8c61<\/h4>\n<\/p>\n<p><p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u9700\u8981\u521b\u5efa\u6e38\u620f\u5bf9\u8c61\uff0c\u5e76\u521d\u59cb\u5316\u5b83\u4eec\u7684\u4f4d\u7f6e\u548c\u5c5e\u6027\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">ball = Ball(400, 300, 10, (255, 0, 0))<\/p>\n<p>paddle = Paddle(350, 550, 100, 10, (0, 255, 0))<\/p>\n<p>bricks = []<\/p>\n<p>for i in range(5):<\/p>\n<p>    for j in range(10):<\/p>\n<p>        bricks.append(Brick(60 + j * 70, 50 + i * 30, 60, 20, (0, 0, 255)))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e00\u4e2a\u7403\u5bf9\u8c61\u3001\u4e00\u4e2a\u6321\u677f\u5bf9\u8c61\u548c\u4e00\u4e2a\u7816\u5757\u5217\u8868\u3002\u7816\u5757\u5bf9\u8c61\u901a\u8fc7\u5d4c\u5957\u5faa\u73af\u521b\u5efa\uff0c\u5e76\u6dfb\u52a0\u5230\u7816\u5757\u5217\u8868\u4e2d\u3002<\/p>\n<\/p>\n<p><h4>4. \u5904\u7406\u4e8b\u4ef6\u548c\u66f4\u65b0\u6e38\u620f\u72b6\u6001<\/h4>\n<\/p>\n<p><p>\u5728\u6e38\u620f\u5faa\u73af\u4e2d\uff0c\u6211\u4eec\u9700\u8981\u5904\u7406\u7528\u6237\u8f93\u5165\uff0c\u5e76\u66f4\u65b0\u6e38\u620f\u5bf9\u8c61\u7684\u72b6\u6001\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">running = True<\/p>\n<p>clock = pygame.time.Clock()<\/p>\n<p>while running:<\/p>\n<p>    for event in pygame.event.get():<\/p>\n<p>        if event.type == pygame.QUIT:<\/p>\n<p>            running = False<\/p>\n<p>    keys = pygame.key.get_pressed()<\/p>\n<p>    if keys[pygame.K_LEFT]:<\/p>\n<p>        paddle.move(&quot;left&quot;)<\/p>\n<p>    if keys[pygame.K_RIGHT]:<\/p>\n<p>        paddle.move(&quot;right&quot;)<\/p>\n<p>    ball.move()<\/p>\n<p>    # \u78b0\u649e\u68c0\u6d4b<\/p>\n<p>    if ball.x &lt; ball.radius or ball.x &gt; 800 - ball.radius:<\/p>\n<p>        ball.speed_x = -ball.speed_x<\/p>\n<p>    if ball.y &lt; ball.radius:<\/p>\n<p>        ball.speed_y = -ball.speed_y<\/p>\n<p>    if ball.y &gt; 600 - ball.radius:<\/p>\n<p>        running = False  # \u6e38\u620f\u7ed3\u675f<\/p>\n<p>    # \u6321\u677f\u78b0\u649e\u68c0\u6d4b<\/p>\n<p>    if (ball.y + ball.radius &gt; paddle.y and<\/p>\n<p>            paddle.x &lt; ball.x &lt; paddle.x + paddle.width):<\/p>\n<p>        ball.speed_y = -ball.speed_y<\/p>\n<p>    # \u7816\u5757\u78b0\u649e\u68c0\u6d4b<\/p>\n<p>    for brick in bricks:<\/p>\n<p>        if brick.visible and (brick.x &lt; ball.x &lt; brick.x + brick.width and<\/p>\n<p>                              brick.y &lt; ball.y &lt; brick.y + brick.height):<\/p>\n<p>            ball.speed_y = -ball.speed_y<\/p>\n<p>            brick.visible = False<\/p>\n<p>    # \u7ed8\u5236\u56fe\u5f62<\/p>\n<p>    screen.fill((0, 0, 0))  # \u6e05\u5c4f<\/p>\n<p>    ball.draw(screen)<\/p>\n<p>    paddle.draw(screen)<\/p>\n<p>    for brick in bricks:<\/p>\n<p>        brick.draw(screen)<\/p>\n<p>    # \u5237\u65b0\u5c4f\u5e55<\/p>\n<p>    pygame.display.flip()<\/p>\n<p>    # \u63a7\u5236\u5e27\u7387<\/p>\n<p>    clock.tick(60)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u5904\u7406\u4e86\u7528\u6237\u7684\u952e\u76d8\u8f93\u5165\uff0c\u5e76\u6839\u636e\u8f93\u5165\u79fb\u52a8\u6321\u677f\u3002\u63a5\u7740\uff0c\u6211\u4eec\u66f4\u65b0\u4e86\u7403\u7684\u4f4d\u7f6e\uff0c\u5e76\u8fdb\u884c\u4e86\u8fb9\u754c\u78b0\u649e\u68c0\u6d4b\u3001\u6321\u677f\u78b0\u649e\u68c0\u6d4b\u548c\u7816\u5757\u78b0\u649e\u68c0\u6d4b\u3002\u6700\u540e\uff0c\u6211\u4eec\u7ed8\u5236\u4e86\u6240\u6709\u7684\u6e38\u620f\u5bf9\u8c61\uff0c\u5e76\u5237\u65b0\u5c4f\u5e55\u3002<\/p>\n<\/p>\n<p><h4>5. \u5b8c\u6574\u793a\u4f8b\u4ee3\u7801<\/h4>\n<\/p>\n<p><p>\u4e0b\u9762\u662f\u5b8c\u6574\u7684\u6253\u7816\u5757\u6e38\u620f\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pygame<\/p>\n<p>pygame.init()<\/p>\n<p>screen = pygame.display.set_mode((800, 600))<\/p>\n<p>pygame.display.set_caption(&quot;Breakout Game&quot;)<\/p>\n<p>class Ball:<\/p>\n<p>    def __init__(self, x, y, radius, color):<\/p>\n<p>        self.x = x<\/p>\n<p>        self.y = y<\/p>\n<p>        self.radius = radius<\/p>\n<p>        self.color = color<\/p>\n<p>        self.speed_x = 5<\/p>\n<p>        self.speed_y = 5<\/p>\n<p>    def draw(self, screen):<\/p>\n<p>        pygame.draw.circle(screen, self.color, (self.x, self.y), self.radius)<\/p>\n<p>    def move(self):<\/p>\n<p>        self.x += self.speed_x<\/p>\n<p>        self.y += self.speed_y<\/p>\n<p>class Paddle:<\/p>\n<p>    def __init__(self, x, y, width, height, color):<\/p>\n<p>        self.x = x<\/p>\n<p>        self.y = y<\/p>\n<p>        self.width = width<\/p>\n<p>        self.height = height<\/p>\n<p>        self.color = color<\/p>\n<p>        self.speed = 10<\/p>\n<p>    def draw(self, screen):<\/p>\n<p>        pygame.draw.rect(screen, self.color, (self.x, self.y, self.width, self.height))<\/p>\n<p>    def move(self, direction):<\/p>\n<p>        if direction == &quot;left&quot; and self.x &gt; 0:<\/p>\n<p>            self.x -= self.speed<\/p>\n<p>        elif direction == &quot;right&quot; and self.x &lt; 800 - self.width:<\/p>\n<p>            self.x += self.speed<\/p>\n<p>class Brick:<\/p>\n<p>    def __init__(self, x, y, width, height, color):<\/p>\n<p>        self.x = x<\/p>\n<p>        self.y = y<\/p>\n<p>        self.width = width<\/p>\n<p>        self.height = height<\/p>\n<p>        self.color = color<\/p>\n<p>        self.visible = True<\/p>\n<p>    def draw(self, screen):<\/p>\n<p>        if self.visible:<\/p>\n<p>            pygame.draw.rect(screen, self.color, (self.x, self.y, self.width, self.height))<\/p>\n<p>ball = Ball(400, 300, 10, (255, 0, 0))<\/p>\n<p>paddle = Paddle(350, 550, 100, 10, (0, 255, 0))<\/p>\n<p>bricks = []<\/p>\n<p>for i in range(5):<\/p>\n<p>    for j in range(10):<\/p>\n<p>        bricks.append(Brick(60 + j * 70, 50 + i * 30, 60, 20, (0, 0, 255)))<\/p>\n<p>running = True<\/p>\n<p>clock = pygame.time.Clock()<\/p>\n<p>while running:<\/p>\n<p>    for event in pygame.event.get():<\/p>\n<p>        if event.type == pygame.QUIT:<\/p>\n<p>            running = False<\/p>\n<p>    keys = pygame.key.get_pressed()<\/p>\n<p>    if keys[pygame.K_LEFT]:<\/p>\n<p>        paddle.move(&quot;left&quot;)<\/p>\n<p>    if keys[pygame.K_RIGHT]:<\/p>\n<p>        paddle.move(&quot;right&quot;)<\/p>\n<p>    ball.move()<\/p>\n<p>    #<\/p>\n<p><\/code><\/pre>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u9009\u62e9\u9002\u5408\u7684Python\u6e38\u620f\u6a21\u5757\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u6709\u8bb8\u591a\u6e38\u620f\u6a21\u5757\u53ef\u4f9b\u9009\u62e9\uff0c\u5982Pygame\u3001Pyglet\u548cArcade\u7b49\u3002\u9009\u62e9\u65f6\uff0c\u53ef\u4ee5\u8003\u8651\u6e38\u620f\u7684\u7c7b\u578b\u548c\u590d\u6742\u6027\u3002Pygame\u9002\u54082D\u6e38\u620f\u5f00\u53d1\uff0c\u800cPyglet\u66f4\u9002\u5408\u9700\u8981\u66f4\u9ad8\u6027\u80fd\u7684\u56fe\u5f62\u5e94\u7528\u3002Arcade\u5219\u4e3a\u521d\u5b66\u8005\u63d0\u4f9b\u4e86\u7b80\u5355\u6613\u7528\u7684API\u3002\u56e0\u6b64\uff0c\u4e86\u89e3\u5404\u4e2a\u6a21\u5757\u7684\u7279\u70b9\u548c\u9002\u7528\u573a\u666f\u6709\u52a9\u4e8e\u9009\u62e9\u6700\u5408\u9002\u7684\u5de5\u5177\u3002<\/p>\n<p><strong>\u5bfc\u5165Python\u6a21\u5757\u65f6\u9047\u5230\u9519\u8bef\u8be5\u5982\u4f55\u89e3\u51b3\uff1f<\/strong><br \/>\u5728\u5bfc\u5165\u6a21\u5757\u65f6\uff0c\u5e38\u89c1\u7684\u9519\u8bef\u5305\u62ecModuleNotFoundError\u6216ImportError\u3002\u9996\u5148\uff0c\u786e\u4fdd\u6240\u9700\u6a21\u5757\u5df2\u6b63\u786e\u5b89\u88c5\u3002\u53ef\u4ee5\u901a\u8fc7pip\u5de5\u5177\u8fdb\u884c\u5b89\u88c5\uff0c\u6bd4\u5982\u4f7f\u7528\u547d\u4ee4<code>pip install pygame<\/code>\u3002\u5982\u679c\u6a21\u5757\u5df2\u5b89\u88c5\u4f46\u4ecd\u65e0\u6cd5\u5bfc\u5165\uff0c\u68c0\u67e5Python\u73af\u5883\u662f\u5426\u6b63\u786e\u914d\u7f6e\uff0c\u4ee5\u53ca\u662f\u5426\u5728\u6b63\u786e\u7684\u865a\u62df\u73af\u5883\u4e2d\u8fd0\u884c\u4ee3\u7801\u3002<\/p>\n<p><strong>\u5982\u4f55\u4f7f\u7528Python\u6a21\u5757\u521b\u5efa\u7b80\u5355\u7684\u6e38\u620f\u793a\u4f8b\uff1f<\/strong><br \/>\u4f7f\u7528Pygame\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u6e38\u620f\u76f8\u5bf9\u5bb9\u6613\u3002\u53ef\u4ee5\u4ece\u521d\u59cb\u5316Pygame\u5f00\u59cb\uff0c\u8bbe\u7f6e\u6e38\u620f\u7a97\u53e3\u548c\u57fa\u672c\u5faa\u73af\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\u4ee3\u7801\uff1a  <\/p>\n<pre><code class=\"language-python\">import pygame\npygame.init()\nscreen = pygame.display.set_mode((800, 600))\nrunning = True\nwhile running:\n    for event in pygame.event.get():\n        if event.type == pygame.QUIT:\n            running = False\n    screen.fill((0, 0, 0))  # \u586b\u5145\u9ed1\u8272\u80cc\u666f\n    pygame.display.flip()\npygame.quit()\n<\/code><\/pre>\n<p>\u8fd9\u6bb5\u4ee3\u7801\u8bbe\u7f6e\u4e86\u4e00\u4e2a\u57fa\u672c\u7684\u6e38\u620f\u7a97\u53e3\uff0c\u5e76\u5904\u7406\u9000\u51fa\u4e8b\u4ef6\u3002\u901a\u8fc7\u4e0d\u65ad\u66f4\u65b0\u5c4f\u5e55\uff0c\u53ef\u4ee5\u8fdb\u4e00\u6b65\u6dfb\u52a0\u6e38\u620f\u5143\u7d20\u548c\u4ea4\u4e92\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python\u4e2d\u5bfc\u5165\u6a21\u5757\u505a\u6e38\u620f\uff0c\u53ef\u4ee5\u4f7f\u7528\u6807\u51c6\u5e93\u548c\u7b2c\u4e09\u65b9\u5e93\uff0c\u5982pygame\u3001Pygame Zero\u7b49\u3002Pytho [&hellip;]","protected":false},"author":3,"featured_media":1181744,"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\/1181733"}],"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=1181733"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1181733\/revisions"}],"predecessor-version":[{"id":1181747,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1181733\/revisions\/1181747"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1181744"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1181733"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1181733"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1181733"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}