{"id":1067364,"date":"2024-12-31T16:34:05","date_gmt":"2024-12-31T08:34:05","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1067364.html"},"modified":"2024-12-31T16:34:07","modified_gmt":"2024-12-31T08:34:07","slug":"python%e5%a6%82%e4%bd%95%e5%b0%86%e5%88%97%e8%a1%a8%e8%bd%ac%e6%8d%a2%e4%b8%ba%e8%a1%a8%e6%a0%bc","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1067364.html","title":{"rendered":"python\u5982\u4f55\u5c06\u5217\u8868\u8f6c\u6362\u4e3a\u8868\u683c"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2024\/12\/52cfe133-148c-4ed9-aab3-162f41a57257.webp?x-oss-process=image\/auto-orient,1\/format,webp\" alt=\"python\u5982\u4f55\u5c06\u5217\u8868\u8f6c\u6362\u4e3a\u8868\u683c\" \/><\/p>\n<p><p> <strong>\u5728Python\u4e2d\u5c06\u5217\u8868\u8f6c\u6362\u4e3a\u8868\u683c\u53ef\u4ee5\u4f7f\u7528\u591a\u79cd\u65b9\u6cd5\uff0c\u5305\u62ec\u4f7f\u7528Pandas\u3001PrettyTable\u3001Tabulate\u7b49\u5e93\u3002<\/strong>\u5728\u8fd9\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u4eec\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u8fd9\u4e9b\u65b9\u6cd5\uff0c\u5e76\u63d0\u4f9b\u76f8\u5e94\u7684\u4ee3\u7801\u793a\u4f8b\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u4f7f\u7528Pandas<\/p>\n<\/p>\n<p><p>Pandas\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u6570\u636e\u5206\u6790\u548c\u5904\u7406\u5e93\uff0c\u5b83\u63d0\u4f9b\u4e86\u4e00\u4e2a\u7b80\u5355\u7684\u65b9\u6cd5\u6765\u5c06\u5217\u8868\u8f6c\u6362\u4e3a\u8868\u683c\u3002\u4ee5\u4e0b\u662f\u4f7f\u7528Pandas\u5c06\u5217\u8868\u8f6c\u6362\u4e3a\u8868\u683c\u7684\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u5b89\u88c5Pandas<\/li>\n<li>\u521b\u5efa\u4e00\u4e2aDataFrame<\/li>\n<li>\u6253\u5370DataFrame<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<h2><strong>\u793a\u4f8b\u5217\u8868<\/strong><\/h2>\n<p>data = [[&#39;Alice&#39;, 24], [&#39;Bob&#39;, 27], [&#39;Charlie&#39;, 22]]<\/p>\n<h2><strong>\u5c06\u5217\u8868\u8f6c\u6362\u4e3aDataFrame<\/strong><\/h2>\n<p>df = pd.DataFrame(data, columns=[&#39;Name&#39;, &#39;Age&#39;])<\/p>\n<h2><strong>\u6253\u5370DataFrame<\/strong><\/h2>\n<p>print(df)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>\u8be6\u7ec6\u63cf\u8ff0\uff1a\u5b89\u88c5Pandas<\/strong><\/p>\n<\/p>\n<p><p>\u5728\u5f00\u59cb\u4e4b\u524d\uff0c\u6211\u4eec\u9700\u8981\u786e\u4fdd\u5df2\u7ecf\u5b89\u88c5\u4e86Pandas\u5e93\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528pip\u547d\u4ee4\u6765\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install pandas<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4e8c\u3001\u4f7f\u7528PrettyTable<\/p>\n<\/p>\n<p><p>PrettyTable\u662f\u4e00\u4e2aPython\u5e93\uff0c\u7528\u4e8e\u521b\u5efa\u7f8e\u89c2\u7684ASCII\u8868\u683c\u3002\u4ee5\u4e0b\u662f\u4f7f\u7528PrettyTable\u5c06\u5217\u8868\u8f6c\u6362\u4e3a\u8868\u683c\u7684\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u5b89\u88c5PrettyTable<\/li>\n<li>\u521b\u5efa\u4e00\u4e2aPrettyTable\u5bf9\u8c61<\/li>\n<li>\u6dfb\u52a0\u884c\u548c\u5217<\/li>\n<li>\u6253\u5370PrettyTable\u5bf9\u8c61<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">from prettytable import PrettyTable<\/p>\n<h2><strong>\u793a\u4f8b\u5217\u8868<\/strong><\/h2>\n<p>data = [[&#39;Alice&#39;, 24], [&#39;Bob&#39;, 27], [&#39;Charlie&#39;, 22]]<\/p>\n<h2><strong>\u521b\u5efaPrettyTable\u5bf9\u8c61<\/strong><\/h2>\n<p>table = PrettyTable([&#39;Name&#39;, &#39;Age&#39;])<\/p>\n<h2><strong>\u6dfb\u52a0\u884c<\/strong><\/h2>\n<p>for row in data:<\/p>\n<p>    table.add_row(row)<\/p>\n<h2><strong>\u6253\u5370\u8868\u683c<\/strong><\/h2>\n<p>print(table)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>\u8be6\u7ec6\u63cf\u8ff0\uff1a\u5b89\u88c5PrettyTable<\/strong><\/p>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u5b89\u88c5PrettyTable\u5e93\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528pip\u547d\u4ee4\u6765\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install prettytable<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4e09\u3001\u4f7f\u7528Tabulate<\/p>\n<\/p>\n<p><p>Tabulate\u662f\u53e6\u4e00\u4e2aPython\u5e93\uff0c\u7528\u4e8e\u5c06\u5217\u8868\u548c\u5b57\u5178\u8f6c\u6362\u4e3a\u7f8e\u89c2\u7684\u8868\u683c\u3002\u4ee5\u4e0b\u662f\u4f7f\u7528Tabulate\u5c06\u5217\u8868\u8f6c\u6362\u4e3a\u8868\u683c\u7684\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u5b89\u88c5Tabulate<\/li>\n<li>\u4f7f\u7528tabulate\u51fd\u6570<\/li>\n<li>\u6253\u5370\u7ed3\u679c<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">from tabulate import tabulate<\/p>\n<h2><strong>\u793a\u4f8b\u5217\u8868<\/strong><\/h2>\n<p>data = [[&#39;Alice&#39;, 24], [&#39;Bob&#39;, 27], [&#39;Charlie&#39;, 22]]<\/p>\n<h2><strong>\u4f7f\u7528tabulate\u51fd\u6570<\/strong><\/h2>\n<p>table = tabulate(data, headers=[&#39;Name&#39;, &#39;Age&#39;], tablefmt=&#39;grid&#39;)<\/p>\n<h2><strong>\u6253\u5370\u8868\u683c<\/strong><\/h2>\n<p>print(table)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>\u8be6\u7ec6\u63cf\u8ff0\uff1a\u5b89\u88c5Tabulate<\/strong><\/p>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u5b89\u88c5Tabulate\u5e93\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528pip\u547d\u4ee4\u6765\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install tabulate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u56db\u3001\u4f7f\u7528csv\u6a21\u5757<\/p>\n<\/p>\n<p><p>\u5982\u679c\u4f60\u53ea\u9700\u8981\u5c06\u5217\u8868\u8f6c\u6362\u4e3aCSV\u683c\u5f0f\u7684\u8868\u683c\uff0c\u53ef\u4ee5\u4f7f\u7528Python\u5185\u7f6e\u7684csv\u6a21\u5757\u3002\u4ee5\u4e0b\u662f\u4f7f\u7528csv\u6a21\u5757\u5c06\u5217\u8868\u8f6c\u6362\u4e3a\u8868\u683c\u7684\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u5bfc\u5165csv\u6a21\u5757<\/li>\n<li>\u521b\u5efa\u4e00\u4e2aCSV\u6587\u4ef6<\/li>\n<li>\u4f7f\u7528writerow\u51fd\u6570\u5199\u5165\u6570\u636e<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">import csv<\/p>\n<h2><strong>\u793a\u4f8b\u5217\u8868<\/strong><\/h2>\n<p>data = [[&#39;Alice&#39;, 24], [&#39;Bob&#39;, 27], [&#39;Charlie&#39;, 22]]<\/p>\n<h2><strong>\u521b\u5efaCSV\u6587\u4ef6\u5e76\u5199\u5165\u6570\u636e<\/strong><\/h2>\n<p>with open(&#39;output.csv&#39;, &#39;w&#39;, newline=&#39;&#39;) as file:<\/p>\n<p>    writer = csv.writer(file)<\/p>\n<p>    writer.writerow([&#39;Name&#39;, &#39;Age&#39;])<\/p>\n<p>    writer.writerows(data)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>\u8be6\u7ec6\u63cf\u8ff0\uff1a\u521b\u5efaCSV\u6587\u4ef6<\/strong><\/p>\n<\/p>\n<p><p>\u5728\u4f7f\u7528csv\u6a21\u5757\u65f6\uff0c\u6211\u4eec\u9700\u8981\u5148\u521b\u5efa\u4e00\u4e2aCSV\u6587\u4ef6\u3002\u7136\u540e\u4f7f\u7528writerow\u51fd\u6570\u5c06\u6570\u636e\u5199\u5165CSV\u6587\u4ef6\u4e2d\u3002\u8fd9\u4e2a\u65b9\u6cd5\u975e\u5e38\u9002\u5408\u9700\u8981\u5c06\u6570\u636e\u4fdd\u5b58\u4e3aCSV\u6587\u4ef6\u7684\u60c5\u51b5\u3002<\/p>\n<\/p>\n<p><p>\u4e94\u3001\u4f7f\u7528NumPy<\/p>\n<\/p>\n<p><p>NumPy\u662f\u4e00\u4e2a\u7528\u4e8e\u79d1\u5b66\u8ba1\u7b97\u7684\u5e93\uff0c\u5b83\u4e5f\u53ef\u4ee5\u7528\u4e8e\u5c06\u5217\u8868\u8f6c\u6362\u4e3a\u8868\u683c\u3002\u4ee5\u4e0b\u662f\u4f7f\u7528NumPy\u5c06\u5217\u8868\u8f6c\u6362\u4e3a\u8868\u683c\u7684\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u5b89\u88c5NumPy<\/li>\n<li>\u521b\u5efa\u4e00\u4e2aNumPy\u6570\u7ec4<\/li>\n<li>\u6253\u5370\u6570\u7ec4<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<h2><strong>\u793a\u4f8b\u5217\u8868<\/strong><\/h2>\n<p>data = [[&#39;Alice&#39;, 24], [&#39;Bob&#39;, 27], [&#39;Charlie&#39;, 22]]<\/p>\n<h2><strong>\u5c06\u5217\u8868\u8f6c\u6362\u4e3aNumPy\u6570\u7ec4<\/strong><\/h2>\n<p>array = np.array(data)<\/p>\n<h2><strong>\u6253\u5370\u6570\u7ec4<\/strong><\/h2>\n<p>print(array)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>\u8be6\u7ec6\u63cf\u8ff0\uff1a\u5b89\u88c5NumPy<\/strong><\/p>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u5b89\u88c5NumPy\u5e93\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528pip\u547d\u4ee4\u6765\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install numpy<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u516d\u3001\u4f7f\u7528pandas.DataFrame\u7684to_markdown\u65b9\u6cd5<\/p>\n<\/p>\n<p><p>\u5982\u679c\u4f60\u9700\u8981\u5c06\u8868\u683c\u8f6c\u6362\u4e3aMarkdown\u683c\u5f0f\uff0c\u53ef\u4ee5\u4f7f\u7528Pandas\u5e93\u7684to_markdown\u65b9\u6cd5\u3002\u4ee5\u4e0b\u662f\u4f7f\u7528to_markdown\u65b9\u6cd5\u5c06\u5217\u8868\u8f6c\u6362\u4e3a\u8868\u683c\u7684\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u5b89\u88c5Pandas<\/li>\n<li>\u521b\u5efa\u4e00\u4e2aDataFrame<\/li>\n<li>\u4f7f\u7528to_markdown\u65b9\u6cd5<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<h2><strong>\u793a\u4f8b\u5217\u8868<\/strong><\/h2>\n<p>data = [[&#39;Alice&#39;, 24], [&#39;Bob&#39;, 27], [&#39;Charlie&#39;, 22]]<\/p>\n<h2><strong>\u5c06\u5217\u8868\u8f6c\u6362\u4e3aDataFrame<\/strong><\/h2>\n<p>df = pd.DataFrame(data, columns=[&#39;Name&#39;, &#39;Age&#39;])<\/p>\n<h2><strong>\u5c06DataFrame\u8f6c\u6362\u4e3aMarkdown\u683c\u5f0f<\/strong><\/h2>\n<p>markdown_table = df.to_markdown(index=False)<\/p>\n<h2><strong>\u6253\u5370Markdown\u8868\u683c<\/strong><\/h2>\n<p>print(markdown_table)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4e03\u3001\u4f7f\u7528PrettyTable\u548cHTMLTable<\/p>\n<\/p>\n<p><p>\u5982\u679c\u4f60\u9700\u8981\u5c06\u8868\u683c\u8f6c\u6362\u4e3aHTML\u683c\u5f0f\uff0c\u53ef\u4ee5\u4f7f\u7528PrettyTable\u548cHTMLTable\u5e93\u3002\u4ee5\u4e0b\u662f\u4f7f\u7528PrettyTable\u548cHTMLTable\u5c06\u5217\u8868\u8f6c\u6362\u4e3a\u8868\u683c\u7684\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u5b89\u88c5PrettyTable\u548cHTMLTable<\/li>\n<li>\u521b\u5efa\u4e00\u4e2aPrettyTable\u5bf9\u8c61<\/li>\n<li>\u8f6c\u6362\u4e3aHTML\u683c\u5f0f<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">from prettytable import PrettyTable<\/p>\n<p>from htmltable import HTMLTable<\/p>\n<h2><strong>\u793a\u4f8b\u5217\u8868<\/strong><\/h2>\n<p>data = [[&#39;Alice&#39;, 24], [&#39;Bob&#39;, 27], [&#39;Charlie&#39;, 22]]<\/p>\n<h2><strong>\u521b\u5efaPrettyTable\u5bf9\u8c61<\/strong><\/h2>\n<p>table = PrettyTable([&#39;Name&#39;, &#39;Age&#39;])<\/p>\n<h2><strong>\u6dfb\u52a0\u884c<\/strong><\/h2>\n<p>for row in data:<\/p>\n<p>    table.add_row(row)<\/p>\n<h2><strong>\u5c06PrettyTable\u8f6c\u6362\u4e3aHTML\u683c\u5f0f<\/strong><\/h2>\n<p>html_table = HTMLTable(table)<\/p>\n<h2><strong>\u6253\u5370HTML\u8868\u683c<\/strong><\/h2>\n<p>print(html_table)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>\u8be6\u7ec6\u63cf\u8ff0\uff1a\u5b89\u88c5PrettyTable\u548cHTMLTable<\/strong><\/p>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u5b89\u88c5PrettyTable\u548cHTMLTable\u5e93\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528pip\u547d\u4ee4\u6765\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install prettytable<\/p>\n<p>pip install htmltable<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u516b\u3001\u4f7f\u7528Google Colab<\/p>\n<\/p>\n<p><p>\u5982\u679c\u4f60\u5728Google Colab\u4e2d\u5de5\u4f5c\uff0c\u53ef\u4ee5\u4f7f\u7528\u5185\u7f6e\u7684display\u51fd\u6570\u548cPandas\u5e93\u6765\u5c06\u5217\u8868\u8f6c\u6362\u4e3a\u8868\u683c\u3002\u4ee5\u4e0b\u662f\u4f7f\u7528Google Colab\u5c06\u5217\u8868\u8f6c\u6362\u4e3a\u8868\u683c\u7684\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u5b89\u88c5Pandas<\/li>\n<li>\u521b\u5efa\u4e00\u4e2aDataFrame<\/li>\n<li>\u4f7f\u7528display\u51fd\u6570<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<p>from IPython.display import display<\/p>\n<h2><strong>\u793a\u4f8b\u5217\u8868<\/strong><\/h2>\n<p>data = [[&#39;Alice&#39;, 24], [&#39;Bob&#39;, 27], [&#39;Charlie&#39;, 22]]<\/p>\n<h2><strong>\u5c06\u5217\u8868\u8f6c\u6362\u4e3aDataFrame<\/strong><\/h2>\n<p>df = pd.DataFrame(data, columns=[&#39;Name&#39;, &#39;Age&#39;])<\/p>\n<h2><strong>\u5728Google Colab\u4e2d\u663e\u793a\u8868\u683c<\/strong><\/h2>\n<p>display(df)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u603b\u7ed3<\/p>\n<\/p>\n<p><p>\u5728Python\u4e2d\uff0c\u5c06\u5217\u8868\u8f6c\u6362\u4e3a\u8868\u683c\u6709\u591a\u79cd\u65b9\u6cd5\uff0c\u5305\u62ec\u4f7f\u7528Pandas\u3001PrettyTable\u3001Tabulate\u3001csv\u6a21\u5757\u3001NumPy\u3001Markdown\u683c\u5f0f\u3001HTML\u683c\u5f0f\u548cGoogle Colab\u3002\u6bcf\u79cd\u65b9\u6cd5\u90fd\u6709\u5176\u72ec\u7279\u7684\u4f18\u52bf\u548c\u9002\u7528\u573a\u666f\u3002\u901a\u8fc7\u9009\u62e9\u9002\u5408\u4f60\u7684\u9879\u76ee\u9700\u6c42\u7684\u65b9\u6cd5\uff0c\u4f60\u53ef\u4ee5\u8f7b\u677e\u5730\u5c06\u5217\u8868\u8f6c\u6362\u4e3a\u7f8e\u89c2\u7684\u8868\u683c\u3002\u5e0c\u671b\u8fd9\u7bc7\u6587\u7ae0\u80fd\u5e2e\u52a9\u4f60\u66f4\u597d\u5730\u7406\u89e3\u548c\u5e94\u7528\u8fd9\u4e9b\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u5c06\u5217\u8868\u8f6c\u6362\u4e3a\u8868\u683c\u683c\u5f0f\uff1f<\/strong><\/p>\n<p>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u591a\u4e2a\u5e93\u6765\u5c06\u5217\u8868\u8f6c\u6362\u4e3a\u8868\u683c\u683c\u5f0f\uff0c\u5176\u4e2d\u6700\u5e38\u7528\u7684\u662fPandas\u548cPrettyTable\u3002Pandas\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u6570\u636e\u5904\u7406\u529f\u80fd\uff0c\u53ef\u4ee5\u8f7b\u677e\u5c06\u5217\u8868\u8f6c\u6362\u4e3aDataFrame\uff0c\u800cPrettyTable\u5219\u9002\u5408\u751f\u6210\u7b80\u5355\u7684\u6587\u672c\u8868\u683c\u3002\u53ea\u9700\u7b80\u5355\u7684\u4ee3\u7801\u5c31\u53ef\u4ee5\u5b9e\u73b0\u8fd9\u4e00\u529f\u80fd\uff0c\u4f8b\u5982\u4f7f\u7528Pandas\u7684<code>pd.DataFrame()<\/code>\u51fd\u6570\uff0c\u6216\u8005\u4f7f\u7528PrettyTable\u521b\u5efa\u4e00\u4e2a\u8868\u683c\u5bf9\u8c61\u5e76\u6dfb\u52a0\u6570\u636e\u3002<\/p>\n<p><strong>\u4f7f\u7528Python\u5c06\u5d4c\u5957\u5217\u8868\u8f6c\u6362\u4e3a\u8868\u683c\u65f6\u9700\u8981\u6ce8\u610f\u4ec0\u4e48\uff1f<\/strong><\/p>\n<p>\u5f53\u5904\u7406\u5d4c\u5957\u5217\u8868\u65f6\uff0c\u786e\u4fdd\u6bcf\u4e2a\u5185\u90e8\u5217\u8868\u7684\u957f\u5ea6\u4e00\u81f4\uff0c\u4ee5\u4fbf\u6b63\u786e\u751f\u6210\u8868\u683c\u3002\u5982\u679c\u5185\u90e8\u5217\u8868\u957f\u5ea6\u4e0d\u4e00\u81f4\uff0c\u53ef\u80fd\u4f1a\u5bfc\u81f4\u751f\u6210\u7684\u8868\u683c\u683c\u5f0f\u9519\u4e71\u3002\u6b64\u5916\uff0c\u60a8\u8fd8\u53ef\u4ee5\u4e3a\u8868\u683c\u6dfb\u52a0\u5217\u6807\u9898\uff0c\u4ee5\u63d0\u9ad8\u53ef\u8bfb\u6027\u3002\u4f7f\u7528Pandas\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e<code>columns<\/code>\u53c2\u6570\u6765\u4e3aDataFrame\u6307\u5b9a\u5217\u540d\u3002<\/p>\n<p><strong>\u6709\u54ea\u4e9bPython\u5e93\u53ef\u4ee5\u5e2e\u52a9\u5c06\u5217\u8868\u8f6c\u6362\u4e3a\u8868\u683c\uff1f<\/strong><\/p>\n<p>\u5728Python\u4e2d\uff0c\u6709\u591a\u4e2a\u5e93\u53ef\u4ee5\u5e2e\u52a9\u5c06\u5217\u8868\u8f6c\u6362\u4e3a\u8868\u683c\uff0c\u6700\u5e38\u89c1\u7684\u5305\u62ecPandas\u3001PrettyTable\u548cTabulate\u3002Pandas\u9002\u5408\u5904\u7406\u5927\u578b\u6570\u636e\u96c6\u548c\u590d\u6742\u6570\u636e\u64cd\u4f5c\uff0cPrettyTable\u9002\u5408\u7b80\u5355\u7684\u547d\u4ee4\u884c\u8f93\u51fa\uff0c\u800cTabulate\u5219\u53ef\u4ee5\u751f\u6210\u591a\u79cd\u683c\u5f0f\u7684\u8868\u683c\uff08\u5982Markdown\u3001HTML\u7b49\uff09\uff0c\u7528\u6237\u53ef\u4ee5\u6839\u636e\u5177\u4f53\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u5e93\u6765\u5b9e\u73b0\u5217\u8868\u5230\u8868\u683c\u7684\u8f6c\u6362\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python\u4e2d\u5c06\u5217\u8868\u8f6c\u6362\u4e3a\u8868\u683c\u53ef\u4ee5\u4f7f\u7528\u591a\u79cd\u65b9\u6cd5\uff0c\u5305\u62ec\u4f7f\u7528Pandas\u3001PrettyTable\u3001Tabulat [&hellip;]","protected":false},"author":3,"featured_media":1067368,"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\/1067364"}],"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=1067364"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1067364\/revisions"}],"predecessor-version":[{"id":1067372,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1067364\/revisions\/1067372"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1067368"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1067364"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1067364"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1067364"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}