{"id":1149460,"date":"2025-01-13T16:49:45","date_gmt":"2025-01-13T08:49:45","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1149460.html"},"modified":"2025-01-13T16:49:47","modified_gmt":"2025-01-13T08:49:47","slug":"%e5%a6%82%e4%bd%95%e7%94%a8python%e5%86%99excel","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1149460.html","title":{"rendered":"\u5982\u4f55\u7528python\u5199excel"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25180130\/deb829d7-0659-41a4-ac22-dca2f48453f4.webp\" alt=\"\u5982\u4f55\u7528python\u5199excel\" \/><\/p>\n<p><p> \u8981\u7528Python\u5199Excel\u8868\u683c\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u51e0\u4e2a\u6838\u5fc3\u5e93\uff1a<strong>openpyxl\u3001pandas\u3001xlsxwriter<\/strong>\u3002\u5176\u4e2d\uff0c<strong>openpyxl<\/strong>\u662f\u6700\u5e38\u7528\u7684\u5e93\u4e4b\u4e00\uff0c\u56e0\u4e3a\u5b83\u4e0d\u4ec5\u53ef\u4ee5\u8bfb\u53d6\u548c\u5199\u5165Excel\u6587\u4ef6\uff0c\u8fd8\u652f\u6301\u5bf9\u5355\u5143\u683c\u6837\u5f0f\u3001\u516c\u5f0f\u3001\u56fe\u8868\u7b49\u8fdb\u884c\u64cd\u4f5c\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528\u8fd9\u4e9b\u5e93\u6765\u5904\u7406Excel\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u4f7f\u7528openpyxl\u5e93<\/h3>\n<\/p>\n<p><h4>1. \u5b89\u88c5openpyxl<\/h4>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u9700\u8981\u5b89\u88c5<code>openpyxl<\/code>\u5e93\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install openpyxl<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. \u521b\u5efa\u4e00\u4e2a\u65b0\u7684Excel\u6587\u4ef6<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">from openpyxl import Workbook<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2a\u5de5\u4f5c\u7c3f<\/strong><\/h2>\n<p>wb = Workbook()<\/p>\n<h2><strong>\u6fc0\u6d3b\u4e00\u4e2a\u5de5\u4f5c\u8868<\/strong><\/h2>\n<p>ws = wb.active<\/p>\n<h2><strong>\u5728\u5355\u5143\u683c\u4e2d\u5199\u5165\u6570\u636e<\/strong><\/h2>\n<p>ws[&#39;A1&#39;] = &#39;Hello&#39;<\/p>\n<p>ws[&#39;B1&#39;] = &#39;World&#39;<\/p>\n<h2><strong>\u4fdd\u5b58\u6587\u4ef6<\/strong><\/h2>\n<p>wb.save(&#39;example.xlsx&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3. \u4fee\u6539\u73b0\u6709\u7684Excel\u6587\u4ef6<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">from openpyxl import load_workbook<\/p>\n<h2><strong>\u52a0\u8f7d\u73b0\u6709\u7684\u5de5\u4f5c\u7c3f<\/strong><\/h2>\n<p>wb = load_workbook(&#39;example.xlsx&#39;)<\/p>\n<h2><strong>\u9009\u62e9\u4e00\u4e2a\u5de5\u4f5c\u8868<\/strong><\/h2>\n<p>ws = wb.active<\/p>\n<h2><strong>\u4fee\u6539\u5355\u5143\u683c\u4e2d\u7684\u6570\u636e<\/strong><\/h2>\n<p>ws[&#39;A1&#39;] = &#39;Changed&#39;<\/p>\n<h2><strong>\u4fdd\u5b58\u6587\u4ef6<\/strong><\/h2>\n<p>wb.save(&#39;example.xlsx&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>4. \u6dfb\u52a0\u6837\u5f0f<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">from openpyxl.styles import Font, Color, Alignment<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2a\u5de5\u4f5c\u7c3f<\/strong><\/h2>\n<p>wb = Workbook()<\/p>\n<p>ws = wb.active<\/p>\n<h2><strong>\u8bbe\u7f6e\u5b57\u4f53\u6837\u5f0f<\/strong><\/h2>\n<p>font = Font(name=&#39;Arial&#39;, size=14, bold=True, color=&#39;FF0000&#39;)<\/p>\n<p>ws[&#39;A1&#39;].font = font<\/p>\n<h2><strong>\u8bbe\u7f6e\u5355\u5143\u683c\u5bf9\u9f50\u65b9\u5f0f<\/strong><\/h2>\n<p>alignment = Alignment(horizontal=&#39;center&#39;, vertical=&#39;center&#39;)<\/p>\n<p>ws[&#39;A1&#39;].alignment = alignment<\/p>\n<h2><strong>\u4fdd\u5b58\u6587\u4ef6<\/strong><\/h2>\n<p>wb.save(&#39;styled.xlsx&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e8c\u3001\u4f7f\u7528pandas\u5e93<\/h3>\n<\/p>\n<p><h4>1. \u5b89\u88c5pandas<\/h4>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install pandas openpyxl<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. \u521b\u5efa\u4e00\u4e2a\u65b0\u7684Excel\u6587\u4ef6<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2aDataFrame<\/strong><\/h2>\n<p>data = {&#39;Name&#39;: [&#39;John&#39;, &#39;Anna&#39;, &#39;Peter&#39;, &#39;Linda&#39;],<\/p>\n<p>        &#39;Age&#39;: [28, 24, 35, 32]}<\/p>\n<p>df = pd.DataFrame(data)<\/p>\n<h2><strong>\u5199\u5165Excel\u6587\u4ef6<\/strong><\/h2>\n<p>df.to_excel(&#39;pandas_example.xlsx&#39;, index=False)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3. \u8bfb\u53d6\u548c\u4fee\u6539Excel\u6587\u4ef6<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\"># \u8bfb\u53d6Excel\u6587\u4ef6<\/p>\n<p>df = pd.read_excel(&#39;pandas_example.xlsx&#39;)<\/p>\n<h2><strong>\u4fee\u6539\u6570\u636e<\/strong><\/h2>\n<p>df.loc[0, &#39;Name&#39;] = &#39;Mike&#39;<\/p>\n<h2><strong>\u4fdd\u5b58\u6587\u4ef6<\/strong><\/h2>\n<p>df.to_excel(&#39;pandas_example_modified.xlsx&#39;, index=False)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e09\u3001\u4f7f\u7528xlsxwriter\u5e93<\/h3>\n<\/p>\n<p><h4>1. \u5b89\u88c5xlsxwriter<\/h4>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install xlsxwriter<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. \u521b\u5efa\u4e00\u4e2a\u65b0\u7684Excel\u6587\u4ef6<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">import xlsxwriter<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2a\u5de5\u4f5c\u7c3f<\/strong><\/h2>\n<p>workbook = xlsxwriter.Workbook(&#39;xlsxwriter_example.xlsx&#39;)<\/p>\n<h2><strong>\u6dfb\u52a0\u4e00\u4e2a\u5de5\u4f5c\u8868<\/strong><\/h2>\n<p>worksheet = workbook.add_worksheet()<\/p>\n<h2><strong>\u5199\u5165\u6570\u636e<\/strong><\/h2>\n<p>worksheet.write(&#39;A1&#39;, &#39;Hello&#39;)<\/p>\n<p>worksheet.write(&#39;B1&#39;, &#39;World&#39;)<\/p>\n<h2><strong>\u5173\u95ed\u5de5\u4f5c\u7c3f<\/strong><\/h2>\n<p>workbook.close()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3. \u6dfb\u52a0\u6837\u5f0f\u548c\u683c\u5f0f<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\"># \u521b\u5efa\u4e00\u4e2a\u5de5\u4f5c\u7c3f<\/p>\n<p>workbook = xlsxwriter.Workbook(&#39;formatted.xlsx&#39;)<\/p>\n<p>worksheet = workbook.add_worksheet()<\/p>\n<h2><strong>\u521b\u5efa\u683c\u5f0f\u5bf9\u8c61<\/strong><\/h2>\n<p>bold = workbook.add_format({&#39;bold&#39;: True, &#39;font_color&#39;: &#39;red&#39;})<\/p>\n<h2><strong>\u5e94\u7528\u683c\u5f0f<\/strong><\/h2>\n<p>worksheet.write(&#39;A1&#39;, &#39;Hello&#39;, bold)<\/p>\n<p>worksheet.write(&#39;B1&#39;, &#39;World&#39;, bold)<\/p>\n<h2><strong>\u5173\u95ed\u5de5\u4f5c\u7c3f<\/strong><\/h2>\n<p>workbook.close()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u56db\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p><strong>openpyxl<\/strong>\u3001<strong>pandas<\/strong>\u548c<strong>xlsxwriter<\/strong>\u90fd\u662f\u975e\u5e38\u5f3a\u5927\u7684\u5de5\u5177\uff0c\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u7528Python\u6765\u5904\u7406Excel\u6587\u4ef6\u3002<strong>openpyxl<\/strong>\u9002\u5408\u5904\u7406\u590d\u6742\u7684Excel\u6587\u4ef6\u64cd\u4f5c\uff0c\u5982\u4fee\u6539\u5355\u5143\u683c\u6837\u5f0f\u3001\u6dfb\u52a0\u516c\u5f0f\u7b49\uff1b<strong>pandas<\/strong>\u5219\u66f4\u9002\u5408\u7528\u4e8e\u6570\u636e\u5206\u6790\u548c\u5904\u7406\uff0c\u80fd\u591f\u65b9\u4fbf\u5730\u8bfb\u53d6\u548c\u5199\u5165Excel\u6587\u4ef6\uff1b<strong>xlsxwriter<\/strong>\u5219\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u683c\u5f0f\u5316\u9009\u9879\uff0c\u9002\u5408\u7528\u4e8e\u521b\u5efa\u5e26\u6709\u7279\u5b9a\u683c\u5f0f\u7684Excel\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><p>\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u53ef\u4ee5\u6839\u636e\u5177\u4f53\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u5e93\u3002\u5982\u679c\u9700\u8981\u5904\u7406\u5927\u91cf\u6570\u636e\uff0c\u53ef\u4ee5\u9009\u62e9<strong>pandas<\/strong>\uff1b\u5982\u679c\u9700\u8981\u8fdb\u884c\u590d\u6742\u7684Excel\u64cd\u4f5c\uff0c\u53ef\u4ee5\u9009\u62e9<strong>openpyxl<\/strong>\uff1b\u5982\u679c\u9700\u8981\u521b\u5efa\u5e26\u6709\u7279\u5b9a\u683c\u5f0f\u7684Excel\u6587\u4ef6\uff0c\u53ef\u4ee5\u9009\u62e9<strong>xlsxwriter<\/strong>\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001\u8be6\u7ec6\u8bb2\u89e3openpyxl\u5e93\u7684\u4f7f\u7528<\/h3>\n<\/p>\n<p><h4>1. \u521b\u5efa\u548c\u4fdd\u5b58\u5de5\u4f5c\u7c3f<\/h4>\n<\/p>\n<p><p>\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5de5\u4f5c\u7c3f\u662f\u4f7f\u7528openpyxl\u7684\u7b2c\u4e00\u6b65\u3002\u5de5\u4f5c\u7c3f\u4e2d\u5305\u542b\u591a\u4e2a\u5de5\u4f5c\u8868\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u4f1a\u521b\u5efa\u4e00\u4e2a\u5de5\u4f5c\u8868\u3002\u4ee5\u4e0b\u662f\u521b\u5efa\u548c\u4fdd\u5b58\u5de5\u4f5c\u7c3f\u7684\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from openpyxl import Workbook<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2a\u5de5\u4f5c\u7c3f<\/strong><\/h2>\n<p>wb = Workbook()<\/p>\n<h2><strong>\u6fc0\u6d3b\u9ed8\u8ba4\u7684\u5de5\u4f5c\u8868<\/strong><\/h2>\n<p>ws = wb.active<\/p>\n<h2><strong>\u5728\u5355\u5143\u683c\u4e2d\u5199\u5165\u6570\u636e<\/strong><\/h2>\n<p>ws[&#39;A1&#39;] = &#39;Hello&#39;<\/p>\n<p>ws[&#39;B1&#39;] = &#39;World&#39;<\/p>\n<h2><strong>\u4fdd\u5b58\u5de5\u4f5c\u7c3f<\/strong><\/h2>\n<p>wb.save(&#39;example.xlsx&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. \u52a0\u8f7d\u548c\u4fee\u6539\u73b0\u6709\u7684\u5de5\u4f5c\u7c3f<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u4f7f\u7528<code>load_workbook<\/code>\u51fd\u6570\u52a0\u8f7d\u73b0\u6709\u7684\u5de5\u4f5c\u7c3f\uff0c\u7136\u540e\u5bf9\u5176\u8fdb\u884c\u4fee\u6539\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from openpyxl import load_workbook<\/p>\n<h2><strong>\u52a0\u8f7d\u73b0\u6709\u7684\u5de5\u4f5c\u7c3f<\/strong><\/h2>\n<p>wb = load_workbook(&#39;example.xlsx&#39;)<\/p>\n<h2><strong>\u9009\u62e9\u9ed8\u8ba4\u7684\u5de5\u4f5c\u8868<\/strong><\/h2>\n<p>ws = wb.active<\/p>\n<h2><strong>\u4fee\u6539\u5355\u5143\u683c\u4e2d\u7684\u6570\u636e<\/strong><\/h2>\n<p>ws[&#39;A1&#39;] = &#39;Changed&#39;<\/p>\n<h2><strong>\u4fdd\u5b58\u5de5\u4f5c\u7c3f<\/strong><\/h2>\n<p>wb.save(&#39;example.xlsx&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3. \u6dfb\u52a0\u548c\u5220\u9664\u5de5\u4f5c\u8868<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u5411\u5de5\u4f5c\u7c3f\u4e2d\u6dfb\u52a0\u65b0\u7684\u5de5\u4f5c\u8868\uff0c\u4e5f\u53ef\u4ee5\u5220\u9664\u4e0d\u9700\u8981\u7684\u5de5\u4f5c\u8868\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u6dfb\u52a0\u65b0\u7684\u5de5\u4f5c\u8868<\/p>\n<p>ws1 = wb.create_sheet(title=&#39;NewSheet&#39;)<\/p>\n<p>ws1[&#39;A1&#39;] = &#39;Data in new sheet&#39;<\/p>\n<h2><strong>\u5220\u9664\u5de5\u4f5c\u8868<\/strong><\/h2>\n<p>wb.remove(wb[&#39;Sheet&#39;])<\/p>\n<h2><strong>\u4fdd\u5b58\u5de5\u4f5c\u7c3f<\/strong><\/h2>\n<p>wb.save(&#39;example.xlsx&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>4. \u64cd\u4f5c\u5355\u5143\u683c<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u4f7f\u7528openpyxl\u5bf9\u5355\u5143\u683c\u8fdb\u884c\u8bfb\u5199\u64cd\u4f5c\uff0c\u8fd8\u53ef\u4ee5\u8bbe\u7f6e\u5355\u5143\u683c\u7684\u6837\u5f0f\u548c\u516c\u5f0f\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from openpyxl.styles import Font, Alignment<\/p>\n<h2><strong>\u8bbe\u7f6e\u5355\u5143\u683c\u7684\u5b57\u4f53\u6837\u5f0f<\/strong><\/h2>\n<p>font = Font(name=&#39;Arial&#39;, size=14, bold=True, color=&#39;FF0000&#39;)<\/p>\n<p>ws[&#39;A1&#39;].font = font<\/p>\n<h2><strong>\u8bbe\u7f6e\u5355\u5143\u683c\u7684\u5bf9\u9f50\u65b9\u5f0f<\/strong><\/h2>\n<p>alignment = Alignment(horizontal=&#39;center&#39;, vertical=&#39;center&#39;)<\/p>\n<p>ws[&#39;A1&#39;].alignment = alignment<\/p>\n<h2><strong>\u8bbe\u7f6e\u5355\u5143\u683c\u7684\u516c\u5f0f<\/strong><\/h2>\n<p>ws[&#39;C1&#39;] = &#39;=SUM(A1:B1)&#39;<\/p>\n<h2><strong>\u4fdd\u5b58\u5de5\u4f5c\u7c3f<\/strong><\/h2>\n<p>wb.save(&#39;example.xlsx&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>5. \u6dfb\u52a0\u56fe\u8868<\/h4>\n<\/p>\n<p><p>openpyxl\u8fd8\u652f\u6301\u5728\u5de5\u4f5c\u8868\u4e2d\u6dfb\u52a0\u56fe\u8868\uff0c\u4f8b\u5982\u67f1\u72b6\u56fe\u3001\u6298\u7ebf\u56fe\u7b49\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from openpyxl.chart import BarChart, Reference<\/p>\n<h2><strong>\u6dfb\u52a0\u6570\u636e<\/strong><\/h2>\n<p>rows = [<\/p>\n<p>    [&#39;Product&#39;, &#39;Sales&#39;],<\/p>\n<p>    [&#39;A&#39;, 30],<\/p>\n<p>    [&#39;B&#39;, 40],<\/p>\n<p>    [&#39;C&#39;, 50],<\/p>\n<p>    [&#39;D&#39;, 60],<\/p>\n<p>]<\/p>\n<p>for row in rows:<\/p>\n<p>    ws.append(row)<\/p>\n<h2><strong>\u521b\u5efa\u67f1\u72b6\u56fe<\/strong><\/h2>\n<p>chart = BarChart()<\/p>\n<p>data = Reference(ws, min_col=2, min_row=1, max_col=2, max_row=5)<\/p>\n<p>categories = Reference(ws, min_col=1, min_row=2, max_row=5)<\/p>\n<p>chart.add_data(data, titles_from_data=True)<\/p>\n<p>chart.set_categories(categories)<\/p>\n<p>chart.title = &quot;Sales Chart&quot;<\/p>\n<h2><strong>\u6dfb\u52a0\u56fe\u8868\u5230\u5de5\u4f5c\u8868<\/strong><\/h2>\n<p>ws.add_chart(chart, &#39;E5&#39;)<\/p>\n<h2><strong>\u4fdd\u5b58\u5de5\u4f5c\u7c3f<\/strong><\/h2>\n<p>wb.save(&#39;chart.xlsx&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u516d\u3001\u8be6\u7ec6\u8bb2\u89e3pandas\u5e93\u7684\u4f7f\u7528<\/h3>\n<\/p>\n<p><h4>1. \u521b\u5efa\u548c\u4fdd\u5b58DataFrame<\/h4>\n<\/p>\n<p><p>\u521b\u5efa\u4e00\u4e2aDataFrame\u662f\u4f7f\u7528pandas\u7684\u7b2c\u4e00\u6b65\uff0c\u53ef\u4ee5\u4ece\u5b57\u5178\u3001\u5217\u8868\u7b49\u6570\u636e\u7ed3\u6784\u521b\u5efaDataFrame\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<h2><strong>\u521b\u5efaDataFrame<\/strong><\/h2>\n<p>data = {&#39;Name&#39;: [&#39;John&#39;, &#39;Anna&#39;, &#39;Peter&#39;, &#39;Linda&#39;],<\/p>\n<p>        &#39;Age&#39;: [28, 24, 35, 32]}<\/p>\n<p>df = pd.DataFrame(data)<\/p>\n<h2><strong>\u4fdd\u5b58DataFrame\u5230Excel\u6587\u4ef6<\/strong><\/h2>\n<p>df.to_excel(&#39;pandas_example.xlsx&#39;, index=False)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. \u8bfb\u53d6\u548c\u4fee\u6539DataFrame<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u4f7f\u7528<code>read_excel<\/code>\u51fd\u6570\u8bfb\u53d6Excel\u6587\u4ef6\uff0c\u7136\u540e\u5bf9DataFrame\u8fdb\u884c\u4fee\u6539\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u8bfb\u53d6Excel\u6587\u4ef6<\/p>\n<p>df = pd.read_excel(&#39;pandas_example.xlsx&#39;)<\/p>\n<h2><strong>\u4fee\u6539\u6570\u636e<\/strong><\/h2>\n<p>df.loc[0, &#39;Name&#39;] = &#39;Mike&#39;<\/p>\n<h2><strong>\u4fdd\u5b58\u4fee\u6539\u540e\u7684DataFrame\u5230Excel\u6587\u4ef6<\/strong><\/h2>\n<p>df.to_excel(&#39;pandas_example_modified.xlsx&#39;, index=False)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3. \u6570\u636e\u5206\u6790\u548c\u5904\u7406<\/h4>\n<\/p>\n<p><p>pandas\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u6570\u636e\u5206\u6790\u548c\u5904\u7406\u529f\u80fd\uff0c\u4f8b\u5982\u7b5b\u9009\u6570\u636e\u3001\u8ba1\u7b97\u7edf\u8ba1\u91cf\u7b49\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u7b5b\u9009\u5e74\u9f84\u5927\u4e8e30\u7684\u6570\u636e<\/p>\n<p>filtered_df = df[df[&#39;Age&#39;] &gt; 30]<\/p>\n<h2><strong>\u8ba1\u7b97\u5e73\u5747\u5e74\u9f84<\/strong><\/h2>\n<p>average_age = df[&#39;Age&#39;].mean()<\/p>\n<h2><strong>\u7edf\u8ba1\u5e74\u9f84\u5206\u5e03<\/strong><\/h2>\n<p>age_distribution = df[&#39;Age&#39;].value_counts()<\/p>\n<h2><strong>\u6253\u5370\u7ed3\u679c<\/strong><\/h2>\n<p>print(filtered_df)<\/p>\n<p>print(&quot;Average Age:&quot;, average_age)<\/p>\n<p>print(&quot;Age Distribution:&quot;)<\/p>\n<p>print(age_distribution)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>4. \u6570\u636e\u53ef\u89c6\u5316<\/h4>\n<\/p>\n<p><p>\u867d\u7136pandas\u672c\u8eab\u4e0d\u63d0\u4f9b\u6570\u636e\u53ef\u89c6\u5316\u529f\u80fd\uff0c\u4f46\u53ef\u4ee5\u4e0ematplotlib\u5e93\u7ed3\u5408\u4f7f\u7528\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import matplotlib.pyplot as plt<\/p>\n<h2><strong>\u521b\u5efa\u67f1\u72b6\u56fe<\/strong><\/h2>\n<p>df.plot(kind=&#39;bar&#39;, x=&#39;Name&#39;, y=&#39;Age&#39;)<\/p>\n<h2><strong>\u663e\u793a\u56fe\u8868<\/strong><\/h2>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e03\u3001\u8be6\u7ec6\u8bb2\u89e3xlsxwriter\u5e93\u7684\u4f7f\u7528<\/h3>\n<\/p>\n<p><h4>1. \u521b\u5efa\u548c\u4fdd\u5b58\u5de5\u4f5c\u7c3f<\/h4>\n<\/p>\n<p><p>\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5de5\u4f5c\u7c3f\u662f\u4f7f\u7528xlsxwriter\u7684\u7b2c\u4e00\u6b65\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u53ef\u4ee5\u6dfb\u52a0\u4e00\u4e2a\u6216\u591a\u4e2a\u5de5\u4f5c\u8868\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import xlsxwriter<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2a\u5de5\u4f5c\u7c3f<\/strong><\/h2>\n<p>workbook = xlsxwriter.Workbook(&#39;xlsxwriter_example.xlsx&#39;)<\/p>\n<h2><strong>\u6dfb\u52a0\u4e00\u4e2a\u5de5\u4f5c\u8868<\/strong><\/h2>\n<p>worksheet = workbook.add_worksheet()<\/p>\n<h2><strong>\u5728\u5355\u5143\u683c\u4e2d\u5199\u5165\u6570\u636e<\/strong><\/h2>\n<p>worksheet.write(&#39;A1&#39;, &#39;Hello&#39;)<\/p>\n<p>worksheet.write(&#39;B1&#39;, &#39;World&#39;)<\/p>\n<h2><strong>\u5173\u95ed\u5de5\u4f5c\u7c3f<\/strong><\/h2>\n<p>workbook.close()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. \u6dfb\u52a0\u683c\u5f0f\u548c\u6837\u5f0f<\/h4>\n<\/p>\n<p><p>xlsxwriter\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u683c\u5f0f\u548c\u6837\u5f0f\u9009\u9879\uff0c\u53ef\u4ee5\u7528\u4e8e\u8bbe\u7f6e\u5355\u5143\u683c\u7684\u5b57\u4f53\u3001\u989c\u8272\u3001\u5bf9\u9f50\u65b9\u5f0f\u7b49\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u521b\u5efa\u683c\u5f0f\u5bf9\u8c61<\/p>\n<p>bold = workbook.add_format({&#39;bold&#39;: True, &#39;font_color&#39;: &#39;red&#39;})<\/p>\n<h2><strong>\u5e94\u7528\u683c\u5f0f\u5230\u5355\u5143\u683c<\/strong><\/h2>\n<p>worksheet.write(&#39;A1&#39;, &#39;Hello&#39;, bold)<\/p>\n<p>worksheet.write(&#39;B1&#39;, &#39;World&#39;, bold)<\/p>\n<h2><strong>\u5173\u95ed\u5de5\u4f5c\u7c3f<\/strong><\/h2>\n<p>workbook.close()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3. \u6dfb\u52a0\u56fe\u8868<\/h4>\n<\/p>\n<p><p>xlsxwriter\u652f\u6301\u6dfb\u52a0\u5404\u79cd\u7c7b\u578b\u7684\u56fe\u8868\uff0c\u4f8b\u5982\u67f1\u72b6\u56fe\u3001\u6298\u7ebf\u56fe\u3001\u997c\u56fe\u7b49\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u521b\u5efa\u6570\u636e<\/p>\n<p>data = [<\/p>\n<p>    [&#39;Product&#39;, &#39;Sales&#39;],<\/p>\n<p>    [&#39;A&#39;, 30],<\/p>\n<p>    [&#39;B&#39;, 40],<\/p>\n<p>    [&#39;C&#39;, 50],<\/p>\n<p>    [&#39;D&#39;, 60],<\/p>\n<p>]<\/p>\n<h2><strong>\u5199\u5165\u6570\u636e\u5230\u5de5\u4f5c\u8868<\/strong><\/h2>\n<p>row = 0<\/p>\n<p>col = 0<\/p>\n<p>for product, sales in data:<\/p>\n<p>    worksheet.write(row, col, product)<\/p>\n<p>    worksheet.write(row, col + 1, sales)<\/p>\n<p>    row += 1<\/p>\n<h2><strong>\u521b\u5efa\u67f1\u72b6\u56fe<\/strong><\/h2>\n<p>chart = workbook.add_chart({&#39;type&#39;: &#39;column&#39;})<\/p>\n<h2><strong>\u914d\u7f6e\u56fe\u8868\u6570\u636e<\/strong><\/h2>\n<p>chart.add_series({<\/p>\n<p>    &#39;categories&#39;: &#39;=Sheet1!$A$2:$A$5&#39;,<\/p>\n<p>    &#39;values&#39;: &#39;=Sheet1!$B$2:$B$5&#39;,<\/p>\n<p>})<\/p>\n<h2><strong>\u6dfb\u52a0\u56fe\u8868\u5230\u5de5\u4f5c\u8868<\/strong><\/h2>\n<p>worksheet.insert_chart(&#39;D2&#39;, chart)<\/p>\n<h2><strong>\u5173\u95ed\u5de5\u4f5c\u7c3f<\/strong><\/h2>\n<p>workbook.close()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u516b\u3001\u5b9e\u6218\u6848\u4f8b<\/h3>\n<\/p>\n<p><p>\u4e3a\u4e86\u66f4\u597d\u5730\u7406\u89e3\u5982\u4f55\u4f7f\u7528\u8fd9\u4e9b\u5e93\uff0c\u6211\u4eec\u5c06\u901a\u8fc7\u4e00\u4e2a\u5b9e\u6218\u6848\u4f8b\u5c55\u793a\u5982\u4f55\u7ed3\u5408\u4f7f\u7528openpyxl\u3001pandas\u548cxlsxwriter\u5e93\u6765\u5904\u7406\u4e00\u4e2aExcel\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><h4>1. \u9700\u6c42\u63cf\u8ff0<\/h4>\n<\/p>\n<p><p>\u5047\u8bbe\u6211\u4eec\u6709\u4e00\u4e2a\u5305\u542b\u5458\u5de5\u4fe1\u606f\u7684Excel\u6587\u4ef6\uff0c\u6587\u4ef6\u5305\u542b\u5458\u5de5\u7684\u59d3\u540d\u3001\u5e74\u9f84\u3001\u804c\u4f4d\u548c\u5de5\u8d44\u3002\u6211\u4eec\u9700\u8981\u5b8c\u6210\u4ee5\u4e0b\u4efb\u52a1\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u4eceExcel\u6587\u4ef6\u4e2d\u8bfb\u53d6\u5458\u5de5\u4fe1\u606f\u3002<\/li>\n<li>\u8ba1\u7b97\u6bcf\u4e2a\u804c\u4f4d\u7684\u5e73\u5747\u5de5\u8d44\u3002<\/li>\n<li>\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Excel\u6587\u4ef6\uff0c\u5305\u542b\u539f\u59cb\u6570\u636e\u548c\u5e73\u5747\u5de5\u8d44\u3002<\/li>\n<li>\u5728\u65b0\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4e00\u4e2a\u67f1\u72b6\u56fe\uff0c\u663e\u793a\u6bcf\u4e2a\u804c\u4f4d\u7684\u5e73\u5747\u5de5\u8d44\u3002<\/li>\n<\/ol>\n<p><h4>2. \u5b9e\u73b0\u6b65\u9aa4<\/h4>\n<\/p>\n<p><p>\u4ee5\u4e0b\u662f\u5b9e\u73b0\u4e0a\u8ff0\u9700\u6c42\u7684Python\u4ee3\u7801\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<p>from openpyxl import Workbook<\/p>\n<p>from openpyxl.chart import BarChart, Reference<\/p>\n<h2><strong>\u8bfb\u53d6\u5458\u5de5\u4fe1\u606f<\/strong><\/h2>\n<p>df = pd.read_excel(&#39;employees.xlsx&#39;)<\/p>\n<h2><strong>\u8ba1\u7b97\u6bcf\u4e2a\u804c\u4f4d\u7684\u5e73\u5747\u5de5\u8d44<\/strong><\/h2>\n<p>average_salary = df.groupby(&#39;Position&#39;)[&#39;Salary&#39;].mean().reset_index()<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5de5\u4f5c\u7c3f<\/strong><\/h2>\n<p>wb = Workbook()<\/p>\n<p>ws = wb.active<\/p>\n<h2><strong>\u5199\u5165\u539f\u59cb\u6570\u636e<\/strong><\/h2>\n<p>for row in dataframe_to_rows(df, index=False, header=True):<\/p>\n<p>    ws.append(row)<\/p>\n<h2><strong>\u5199\u5165\u5e73\u5747\u5de5\u8d44<\/strong><\/h2>\n<p>ws.append([])<\/p>\n<p>ws.append([&#39;Position&#39;, &#39;Average Salary&#39;])<\/p>\n<p>for row in dataframe_to_rows(average_salary, index=False, header=False):<\/p>\n<p>    ws.append(row)<\/p>\n<h2><strong>\u521b\u5efa\u67f1\u72b6\u56fe<\/strong><\/h2>\n<p>chart = BarChart()<\/p>\n<p>data = Reference(ws, min_col=2, min_row=len(df) + 4, max_row=len(df) + len(average_salary) + 3)<\/p>\n<p>categories = Reference(ws, min_col=1, min_row=len(df) + 5, max_row=len(df) + len(average_salary) + 3)<\/p>\n<p>chart.add_data(data, titles_from_data=True)<\/p>\n<p>chart.set_categories(categories)<\/p>\n<p>chart.title = &quot;Average Salary by Position&quot;<\/p>\n<h2><strong>\u6dfb\u52a0\u56fe\u8868\u5230\u5de5\u4f5c\u8868<\/strong><\/h2>\n<p>ws.add_chart(chart, &#39;E5&#39;)<\/p>\n<h2><strong>\u4fdd\u5b58\u5de5\u4f5c\u7c3f<\/strong><\/h2>\n<p>wb.save(&#39;employees_with_chart.xlsx&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u4e0a\u8ff0\u4ee3\u7801\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06\u539f\u59cb\u6570\u636e\u548c\u8ba1\u7b97\u7ed3\u679c\u5199\u5165\u65b0\u7684Excel\u6587\u4ef6\uff0c\u5e76\u6dfb\u52a0\u4e00\u4e2a\u67f1\u72b6\u56fe\u6765\u663e\u793a\u6bcf\u4e2a\u804c\u4f4d\u7684\u5e73\u5747\u5de5\u8d44\u3002\u8fd9\u4e2a\u6848\u4f8b\u5c55\u793a\u4e86\u5982\u4f55\u7ed3\u5408\u4f7f\u7528openpyxl\u548cpandas\u5e93\u6765\u5904\u7406\u548c\u53ef\u89c6\u5316Excel\u6587\u4ef6\u4e2d\u7684\u6570\u636e\u3002<\/p>\n<\/p>\n<p><h3>\u4e5d\u3001\u603b\u7ed3\u4e0e\u6269\u5c55<\/h3>\n<\/p>\n<p><p>\u5728\u8fd9\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u4eec\u8be6\u7ec6\u4ecb\u7ecd\u4e86\u5982\u4f55\u4f7f\u7528Python\u7684openpyxl\u3001pandas\u548cxlsxwriter\u5e93\u6765\u5904\u7406Excel\u6587\u4ef6\u3002\u901a\u8fc7\u5b66\u4e60\u8fd9\u4e9b\u5e93\u7684\u57fa\u672c\u7528\u6cd5\u548c\u9ad8\u7ea7\u529f\u80fd\uff0c\u6211\u4eec\u53ef\u4ee5\u8f7b\u677e\u5730\u8fdb\u884cExcel\u6587\u4ef6\u7684\u521b\u5efa\u3001\u8bfb\u53d6\u3001\u4fee\u6539\u3001\u683c\u5f0f\u5316\u548c\u53ef\u89c6\u5316\u64cd\u4f5c\u3002<\/p>\n<\/p>\n<p><p>\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u53ef\u4ee5\u6839\u636e\u5177\u4f53\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u5e93\uff0c\u5e76\u7ed3\u5408\u4f7f\u7528\u591a\u4e2a\u5e93\u6765\u5b8c\u6210\u590d\u6742\u7684\u4efb\u52a1\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u4f7f\u7528pandas\u8fdb\u884c\u6570\u636e\u5206\u6790\u548c\u5904\u7406\uff0c\u4f7f\u7528openpyxl\u8fdb\u884c\u590d\u6742\u7684Excel\u64cd\u4f5c\uff0c\u4f7f\u7528xlsxwriter\u521b\u5efa\u5e26\u6709\u7279\u5b9a\u683c\u5f0f\u7684Excel\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><p>\u5e0c\u671b\u8fd9\u7bc7\u6587\u7ae0\u5bf9\u60a8\u6709\u6240\u5e2e\u52a9\uff0c\u80fd\u591f\u66f4\u597d\u5730\u7406\u89e3\u548c\u638c\u63e1\u5982\u4f55\u4f7f\u7528Python\u6765\u5904\u7406Excel\u6587\u4ef6\u3002\u5982\u679c\u60a8\u6709\u4efb\u4f55\u95ee\u9898\u6216\u5efa\u8bae\uff0c\u6b22\u8fce\u968f\u65f6\u4e0e\u6211\u4eec\u4ea4\u6d41\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u4f7f\u7528Python\u5e93\u5c06\u6570\u636e\u5199\u5165Excel\u6587\u4ef6\uff1f<\/strong><br \/>\u4f7f\u7528Python\u5199Excel\u6587\u4ef6\u901a\u5e38\u9700\u8981\u4f9d\u8d56\u4e00\u4e9b\u7b2c\u4e09\u65b9\u5e93\uff0c\u5982<code>pandas<\/code>\u548c<code>openpyxl<\/code>\u3002<code>pandas<\/code>\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u6570\u636e\u5904\u7406\u80fd\u529b\uff0c\u800c<code>openpyxl<\/code>\u4e13\u6ce8\u4e8eExcel\u6587\u4ef6\u7684\u8bfb\u5199\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7\u5b89\u88c5\u8fd9\u4e24\u4e2a\u5e93\u6765\u5b9e\u73b0\u6570\u636e\u5199\u5165\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff1a\u9996\u5148\u5b89\u88c5\u5e93\uff0c\u4f7f\u7528\u547d\u4ee4<code>pip install pandas openpyxl<\/code>\uff0c\u7136\u540e\u7528<code>pandas<\/code>\u521b\u5efa\u4e00\u4e2aDataFrame\u5e76\u4f7f\u7528<code>to_excel()<\/code>\u65b9\u6cd5\u4fdd\u5b58\u4e3aExcel\u6587\u4ef6\u3002<\/p>\n<p><strong>\u5728Python\u4e2d\u5982\u4f55\u683c\u5f0f\u5316Excel\u5355\u5143\u683c\uff1f<\/strong><br \/>\u5728\u4f7f\u7528<code>openpyxl<\/code>\u5e93\u65f6\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e\u5355\u5143\u683c\u7684\u6837\u5f0f\u6765\u683c\u5f0f\u5316Excel\u8868\u683c\uff0c\u4f8b\u5982\u66f4\u6539\u5b57\u4f53\u3001\u989c\u8272\u3001\u8fb9\u6846\u7b49\u3002\u53ef\u4ee5\u4f7f\u7528<code>Font<\/code>\u3001<code>Color<\/code>\u3001<code>Border<\/code>\u7b49\u7c7b\u6765\u5b9a\u4e49\u6837\u5f0f\uff0c\u5e76\u5c06\u5176\u5e94\u7528\u5230\u7279\u5b9a\u5355\u5143\u683c\u4e0a\u3002\u683c\u5f0f\u5316\u4ee3\u7801\u793a\u4f8b\u5982\u4e0b\uff1a&#8220;`python<br \/>\nfrom openpyxl import Workbook<br \/>\nfrom openpyxl.styles import Font, Color<\/p>\n<p>wb = Workbook()<br \/>\nws = wb.active<br \/>\nws[&#39;A1&#39;].value = &quot;Hello&quot;<br \/>\nws[&#39;A1&#39;].font = Font(bold=True, color=&quot;FF0000&quot;)  # \u8bbe\u7f6e\u7c97\u4f53\u548c\u7ea2\u8272<br \/>\nwb.save(&quot;formatted.xlsx&quot;)<\/p>\n<pre><code>\n&lt;strong&gt;\u7528Python\u5199Excel\u65f6\u5982\u4f55\u5904\u7406\u591a\u79cd\u6570\u636e\u7c7b\u578b\uff1f&lt;\/strong&gt;  \nPython\u80fd\u591f\u5904\u7406\u591a\u79cd\u6570\u636e\u7c7b\u578b\uff0c\u5982\u5b57\u7b26\u4e32\u3001\u6574\u6570\u3001\u6d6e\u70b9\u6570\u3001\u65e5\u671f\u7b49\u3002\u5728\u5199\u5165Excel\u6587\u4ef6\u65f6\uff0c`pandas`\u548c`openpyxl`\u90fd\u80fd\u81ea\u52a8\u8bc6\u522b\u8fd9\u4e9b\u7c7b\u578b\u3002\u4e3a\u4e86\u786e\u4fdd\u6570\u636e\u7684\u51c6\u786e\u6027\uff0c\u60a8\u53ef\u4ee5\u5728\u521b\u5efaDataFrame\u6216\u5199\u5165\u5355\u5143\u683c\u65f6\u660e\u786e\u6307\u5b9a\u6570\u636e\u7c7b\u578b\u3002\u4f8b\u5982\uff0c\u5728`pandas`\u4e2d\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528`dtype`\u53c2\u6570\u6765\u6307\u5b9a\u5217\u7684\u6570\u636e\u7c7b\u578b\uff0c\u8fd9\u6837\u53ef\u4ee5\u907f\u514d\u7c7b\u578b\u4e0d\u5339\u914d\u7684\u95ee\u9898\uff0c\u786e\u4fddExcel\u6587\u4ef6\u4e2d\u7684\u6570\u636e\u6574\u9f50\u4e14\u6613\u4e8e\u5206\u6790\u3002\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"\u8981\u7528Python\u5199Excel\u8868\u683c\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u51e0\u4e2a\u6838\u5fc3\u5e93\uff1aopenpyxl\u3001pandas\u3001xlsxwriter [&hellip;]","protected":false},"author":3,"featured_media":1149467,"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\/1149460"}],"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=1149460"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1149460\/revisions"}],"predecessor-version":[{"id":1149469,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1149460\/revisions\/1149469"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1149467"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1149460"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1149460"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1149460"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}