{"id":1031350,"date":"2024-12-31T11:24:46","date_gmt":"2024-12-31T03:24:46","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1031350.html"},"modified":"2024-12-31T11:24:48","modified_gmt":"2024-12-31T03:24:48","slug":"python%e5%a6%82%e4%bd%95%e9%87%87%e9%9b%86%e6%95%b0%e6%8d%ae%e5%ba%93%e6%95%b0%e6%8d%ae","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1031350.html","title":{"rendered":"python\u5982\u4f55\u91c7\u96c6\u6570\u636e\u5e93\u6570\u636e"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2024\/12\/61ee6b74-49a4-475e-a758-8d06aff38c8d.webp?x-oss-process=image\/auto-orient,1\/format,webp\" alt=\"python\u5982\u4f55\u91c7\u96c6\u6570\u636e\u5e93\u6570\u636e\" \/><\/p>\n<p><p> <strong>Python\u91c7\u96c6\u6570\u636e\u5e93\u6570\u636e\u7684\u65b9\u6cd5\u5305\u62ec\u4f7f\u7528\u6570\u636e\u5e93\u8fde\u63a5\u5e93\u3001\u6267\u884cSQL\u67e5\u8be2\u3001\u5904\u7406\u548c\u5b58\u50a8\u7ed3\u679c\u3002<\/strong>\u5728\u8fd9\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u4eec\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u901a\u8fc7Python\u8fde\u63a5\u5230\u4e0d\u540c\u7c7b\u578b\u7684\u6570\u636e\u5e93\uff08\u5982MySQL\u3001PostgreSQL\u3001SQLite\u7b49\uff09\uff0c\u5e76\u83b7\u53d6\u6570\u636e\u3002\u6211\u4eec\u5c06\u901a\u8fc7\u5b9e\u9645\u7684\u4ee3\u7801\u793a\u4f8b\u548c\u8be6\u7ec6\u6b65\u9aa4\u6765\u5e2e\u52a9\u60a8\u638c\u63e1\u8fd9\u4e00\u8fc7\u7a0b\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u5b89\u88c5\u5fc5\u8981\u7684\u5e93<\/h3>\n<\/p>\n<p><p>\u5728\u5f00\u59cb\u4e4b\u524d\uff0c\u6211\u4eec\u9700\u8981\u5b89\u88c5\u4e00\u4e9b\u5fc5\u8981\u7684\u5e93\u3002\u4e0d\u540c\u7684\u6570\u636e\u5e93\u9700\u8981\u4e0d\u540c\u7684\u5e93\u6765\u8fdb\u884c\u8fde\u63a5\u548c\u64cd\u4f5c\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<ul>\n<li>MySQL\uff1a<code>mysql-connector-python<\/code><\/li>\n<li>PostgreSQL\uff1a<code>psycopg2<\/code><\/li>\n<li>SQLite\uff1a<code>sqlite3<\/code>\uff08\u5185\u7f6e\u4e8ePython\uff0c\u4e0d\u9700\u8981\u5355\u72ec\u5b89\u88c5\uff09<\/li>\n<\/ul>\n<p><p>\u53ef\u4ee5\u4f7f\u7528<code>pip<\/code>\u547d\u4ee4\u6765\u5b89\u88c5\u8fd9\u4e9b\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install mysql-connector-python psycopg2<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e8c\u3001\u8fde\u63a5\u5230\u6570\u636e\u5e93<\/h3>\n<\/p>\n<p><h4>1\u3001\u8fde\u63a5\u5230MySQL\u6570\u636e\u5e93<\/h4>\n<\/p>\n<p><p>MySQL\u662f\u6700\u6d41\u884c\u7684\u5f00\u6e90\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf\u4e4b\u4e00\u3002\u8981\u8fde\u63a5\u5230MySQL\u6570\u636e\u5e93\uff0c\u60a8\u9700\u8981\u4f7f\u7528<code>mysql-connector-python<\/code>\u5e93\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import mysql.connector<\/p>\n<p>def connect_to_mysql():<\/p>\n<p>    try:<\/p>\n<p>        connection = mysql.connector.connect(<\/p>\n<p>            host=&quot;localhost&quot;,<\/p>\n<p>            user=&quot;your_username&quot;,<\/p>\n<p>            password=&quot;your_password&quot;,<\/p>\n<p>            database=&quot;your_database&quot;<\/p>\n<p>        )<\/p>\n<p>        if connection.is_connected():<\/p>\n<p>            print(&quot;Successfully connected to MySQL database&quot;)<\/p>\n<p>            return connection<\/p>\n<p>    except mysql.connector.Error as err:<\/p>\n<p>        print(f&quot;Error: {err}&quot;)<\/p>\n<p>        return None<\/p>\n<p>mysql_connection = connect_to_mysql()<\/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\u51fd\u6570<code>connect_to_mysql<\/code>\uff0c\u8be5\u51fd\u6570\u7528\u4e8e\u8fde\u63a5\u5230MySQL\u6570\u636e\u5e93\u3002\u60a8\u9700\u8981\u63d0\u4f9b\u6570\u636e\u5e93\u7684\u4e3b\u673a\u540d\u3001\u7528\u6237\u540d\u3001\u5bc6\u7801\u548c\u6570\u636e\u5e93\u540d\u79f0\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u8fde\u63a5\u5230PostgreSQL\u6570\u636e\u5e93<\/h4>\n<\/p>\n<p><p>PostgreSQL\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u5f00\u6e90\u5bf9\u8c61\u5173\u7cfb\u6570\u636e\u5e93\u7cfb\u7edf\u3002\u8981\u8fde\u63a5\u5230PostgreSQL\u6570\u636e\u5e93\uff0c\u60a8\u9700\u8981\u4f7f\u7528<code>psycopg2<\/code>\u5e93\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import psycopg2<\/p>\n<p>def connect_to_postgresql():<\/p>\n<p>    try:<\/p>\n<p>        connection = psycopg2.connect(<\/p>\n<p>            host=&quot;localhost&quot;,<\/p>\n<p>            user=&quot;your_username&quot;,<\/p>\n<p>            password=&quot;your_password&quot;,<\/p>\n<p>            dbname=&quot;your_database&quot;<\/p>\n<p>        )<\/p>\n<p>        print(&quot;Successfully connected to PostgreSQL database&quot;)<\/p>\n<p>        return connection<\/p>\n<p>    except psycopg2.Error as err:<\/p>\n<p>        print(f&quot;Error: {err}&quot;)<\/p>\n<p>        return None<\/p>\n<p>postgresql_connection = connect_to_postgresql()<\/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\u51fd\u6570<code>connect_to_postgresql<\/code>\uff0c\u8be5\u51fd\u6570\u7528\u4e8e\u8fde\u63a5\u5230PostgreSQL\u6570\u636e\u5e93\u3002\u60a8\u9700\u8981\u63d0\u4f9b\u6570\u636e\u5e93\u7684\u4e3b\u673a\u540d\u3001\u7528\u6237\u540d\u3001\u5bc6\u7801\u548c\u6570\u636e\u5e93\u540d\u79f0\u3002<\/p>\n<\/p>\n<p><h4>3\u3001\u8fde\u63a5\u5230SQLite\u6570\u636e\u5e93<\/h4>\n<\/p>\n<p><p>SQLite\u662f\u4e00\u4e2aC\u8bed\u8a00\u5e93\uff0c\u5b9e\u73b0\u4e86\u4e00\u4e2a\u5c0f\u578b\u3001\u5feb\u901f\u3001\u81ea\u7ed9\u81ea\u8db3\u7684SQL\u6570\u636e\u5e93\u5f15\u64ce\u3002SQLite\u662fPython\u5185\u7f6e\u7684\u6570\u636e\u5e93\uff0c\u4e0d\u9700\u8981\u5355\u72ec\u5b89\u88c5\u3002\u8981\u8fde\u63a5\u5230SQLite\u6570\u636e\u5e93\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528<code>sqlite3<\/code>\u5e93\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import sqlite3<\/p>\n<p>def connect_to_sqlite(db_path):<\/p>\n<p>    try:<\/p>\n<p>        connection = sqlite3.connect(db_path)<\/p>\n<p>        print(&quot;Successfully connected to SQLite database&quot;)<\/p>\n<p>        return connection<\/p>\n<p>    except sqlite3.Error as err:<\/p>\n<p>        print(f&quot;Error: {err}&quot;)<\/p>\n<p>        return None<\/p>\n<p>sqlite_connection = connect_to_sqlite(&quot;your_database.db&quot;)<\/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\u51fd\u6570<code>connect_to_sqlite<\/code>\uff0c\u8be5\u51fd\u6570\u7528\u4e8e\u8fde\u63a5\u5230SQLite\u6570\u636e\u5e93\u3002\u60a8\u9700\u8981\u63d0\u4f9b\u6570\u636e\u5e93\u6587\u4ef6\u7684\u8def\u5f84\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u6267\u884cSQL\u67e5\u8be2<\/h3>\n<\/p>\n<p><p>\u4e00\u65e6\u8fde\u63a5\u5230\u6570\u636e\u5e93\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u6267\u884cSQL\u67e5\u8be2\u6765\u83b7\u53d6\u6570\u636e\u3002\u4e0b\u9762\u5206\u522b\u4ecb\u7ecd\u5982\u4f55\u5728MySQL\u3001PostgreSQL\u548cSQLite\u6570\u636e\u5e93\u4e2d\u6267\u884c\u67e5\u8be2\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u5728MySQL\u4e2d\u6267\u884c\u67e5\u8be2<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">def fetch_data_from_mysql(connection):<\/p>\n<p>    try:<\/p>\n<p>        cursor = connection.cursor()<\/p>\n<p>        cursor.execute(&quot;SELECT * FROM your_table&quot;)<\/p>\n<p>        rows = cursor.fetchall()<\/p>\n<p>        for row in rows:<\/p>\n<p>            print(row)<\/p>\n<p>    except mysql.connector.Error as err:<\/p>\n<p>        print(f&quot;Error: {err}&quot;)<\/p>\n<p>    finally:<\/p>\n<p>        cursor.close()<\/p>\n<p>        connection.close()<\/p>\n<p>fetch_data_from_mysql(mysql_connection)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2\u3001\u5728PostgreSQL\u4e2d\u6267\u884c\u67e5\u8be2<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">def fetch_data_from_postgresql(connection):<\/p>\n<p>    try:<\/p>\n<p>        cursor = connection.cursor()<\/p>\n<p>        cursor.execute(&quot;SELECT * FROM your_table&quot;)<\/p>\n<p>        rows = cursor.fetchall()<\/p>\n<p>        for row in rows:<\/p>\n<p>            print(row)<\/p>\n<p>    except psycopg2.Error as err:<\/p>\n<p>        print(f&quot;Error: {err}&quot;)<\/p>\n<p>    finally:<\/p>\n<p>        cursor.close()<\/p>\n<p>        connection.close()<\/p>\n<p>fetch_data_from_postgresql(postgresql_connection)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3\u3001\u5728SQLite\u4e2d\u6267\u884c\u67e5\u8be2<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">def fetch_data_from_sqlite(connection):<\/p>\n<p>    try:<\/p>\n<p>        cursor = connection.cursor()<\/p>\n<p>        cursor.execute(&quot;SELECT * FROM your_table&quot;)<\/p>\n<p>        rows = cursor.fetchall()<\/p>\n<p>        for row in rows:<\/p>\n<p>            print(row)<\/p>\n<p>    except sqlite3.Error as err:<\/p>\n<p>        print(f&quot;Error: {err}&quot;)<\/p>\n<p>    finally:<\/p>\n<p>        cursor.close()<\/p>\n<p>        connection.close()<\/p>\n<p>fetch_data_from_sqlite(sqlite_connection)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u56db\u3001\u5904\u7406\u548c\u5b58\u50a8\u7ed3\u679c<\/h3>\n<\/p>\n<p><p>\u5728\u6267\u884c\u67e5\u8be2\u5e76\u83b7\u53d6\u6570\u636e\u540e\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u5bf9\u6570\u636e\u8fdb\u884c\u5904\u7406\u6216\u5b58\u50a8\u3002\u53ef\u4ee5\u5c06\u6570\u636e\u5b58\u50a8\u5230\u6587\u4ef6\u4e2d\uff0c\u6216\u8fdb\u4e00\u6b65\u5904\u7406\u4ee5\u8fdb\u884c\u5206\u6790\u3002\u4e0b\u9762\u662f\u4e00\u4e9b\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><h4>1\u3001\u5c06\u6570\u636e\u5b58\u50a8\u5230CSV\u6587\u4ef6\u4e2d<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">import csv<\/p>\n<p>def save_to_csv(data, filename):<\/p>\n<p>    with open(filename, mode=&#39;w&#39;, newline=&#39;&#39;) as file:<\/p>\n<p>        writer = csv.writer(file)<\/p>\n<p>        writer.writerow([&quot;Column1&quot;, &quot;Column2&quot;, &quot;Column3&quot;])  # Adjust column names as needed<\/p>\n<p>        writer.writerows(data)<\/p>\n<h2><strong>Example usage:<\/strong><\/h2>\n<h2><strong>save_to_csv(rows, &quot;output.csv&quot;)<\/strong><\/h2>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2\u3001\u5c06\u6570\u636e\u5b58\u50a8\u5230Excel\u6587\u4ef6\u4e2d<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<p>def save_to_excel(data, filename):<\/p>\n<p>    df = pd.DataFrame(data, columns=[&quot;Column1&quot;, &quot;Column2&quot;, &quot;Column3&quot;])  # Adjust column names as needed<\/p>\n<p>    df.to_excel(filename, index=False)<\/p>\n<h2><strong>Example usage:<\/strong><\/h2>\n<h2><strong>save_to_excel(rows, &quot;output.xlsx&quot;)<\/strong><\/h2>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3\u3001\u8fdb\u4e00\u6b65\u5904\u7406\u6570\u636e<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u4f7f\u7528Python\u7684\u5404\u79cd\u6570\u636e\u5904\u7406\u5e93\uff08\u5982Pandas\u3001NumPy\uff09\u6765\u8fdb\u4e00\u6b65\u5904\u7406\u6570\u636e\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u793a\u4f8b\uff0c\u5c55\u793a\u5982\u4f55\u4f7f\u7528Pandas\u6765\u5904\u7406\u6570\u636e\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<p>def process_data(data):<\/p>\n<p>    df = pd.DataFrame(data, columns=[&quot;Column1&quot;, &quot;Column2&quot;, &quot;Column3&quot;])  # Adjust column names as needed<\/p>\n<p>    # Perform data processing here<\/p>\n<p>    print(df.describe())<\/p>\n<h2><strong>Example usage:<\/strong><\/h2>\n<h2><strong>process_data(rows)<\/strong><\/h2>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e94\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u901a\u8fc7\u672c\u6587\u7684\u4ecb\u7ecd\uff0c\u60a8\u5df2\u7ecf\u5b66\u4f1a\u4e86\u5982\u4f55\u4f7f\u7528Python\u8fde\u63a5\u5230\u4e0d\u540c\u7c7b\u578b\u7684\u6570\u636e\u5e93\uff0c\u5e76\u83b7\u53d6\u6570\u636e\u3002\u6211\u4eec\u4ecb\u7ecd\u4e86\u5982\u4f55\u8fde\u63a5\u5230MySQL\u3001PostgreSQL\u548cSQLite\u6570\u636e\u5e93\uff0c\u5982\u4f55\u6267\u884cSQL\u67e5\u8be2\uff0c\u5982\u4f55\u5904\u7406\u548c\u5b58\u50a8\u7ed3\u679c\u3002\u5e0c\u671b\u8fd9\u4e9b\u5185\u5bb9\u5bf9\u60a8\u6709\u6240\u5e2e\u52a9\u3002<\/p>\n<\/p>\n<p><p>\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u60a8\u53ef\u4ee5\u6839\u636e\u5177\u4f53\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u6570\u636e\u5e93\u548c\u6570\u636e\u5904\u7406\u65b9\u6cd5\u3002Python\u5f3a\u5927\u7684\u5e93\u751f\u6001\u7cfb\u7edf\u4f7f\u5f97\u6570\u636e\u91c7\u96c6\u548c\u5904\u7406\u53d8\u5f97\u975e\u5e38\u4fbf\u6377\u3002\u5e0c\u671b\u60a8\u80fd\u901a\u8fc7\u672c\u6587\u638c\u63e1\u8fd9\u4e9b\u6280\u80fd\uff0c\u5e76\u5728\u5b9e\u9645\u9879\u76ee\u4e2d\u52a0\u4ee5\u5e94\u7528\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u8fde\u63a5\u6570\u636e\u5e93\u4ee5\u8fdb\u884c\u6570\u636e\u91c7\u96c6\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u8fde\u63a5\u6570\u636e\u5e93\u901a\u5e38\u4f7f\u7528<code>sqlite3<\/code>\u3001<code>MySQLdb<\/code>\u6216<code>psycopg2<\/code>\u7b49\u5e93\u3002\u9996\u5148\uff0c\u9700\u8981\u5b89\u88c5\u76f8\u5e94\u7684\u5e93\uff0c\u4f8b\u5982\u4f7f\u7528<code>pip install mysql-connector-python<\/code>\u6765\u5b89\u88c5MySQL\u8fde\u63a5\u5668\u3002\u8fde\u63a5\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u4ee3\u7801\u793a\u4f8b\uff1a<\/p>\n<pre><code class=\"language-python\">import mysql.connector\n\nconn = mysql.connector.connect(\n    host=&#39;localhost&#39;,\n    user=&#39;your_username&#39;,\n    password=&#39;your_password&#39;,\n    database=&#39;your_database&#39;\n)\n\ncursor = conn.cursor()\n<\/code><\/pre>\n<p>\u5efa\u7acb\u8fde\u63a5\u540e\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528SQL\u67e5\u8be2\u6765\u63d0\u53d6\u6240\u9700\u7684\u6570\u636e\u3002<\/p>\n<p><strong>\u5982\u4f55\u4f7f\u7528Python\u4ece\u6570\u636e\u5e93\u4e2d\u63d0\u53d6\u7279\u5b9a\u6570\u636e\uff1f<\/strong><br \/>\u60a8\u53ef\u4ee5\u4f7f\u7528SQL\u7684<code>SELECT<\/code>\u8bed\u53e5\u6765\u63d0\u53d6\u7279\u5b9a\u7684\u6570\u636e\u3002\u4f8b\u5982\uff0c\u5047\u8bbe\u60a8\u8981\u4ece\u540d\u4e3a<code>employees<\/code>\u7684\u8868\u4e2d\u63d0\u53d6\u6240\u6709\u5458\u5de5\u7684\u59d3\u540d\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<pre><code class=\"language-python\">query = &quot;SELECT name FROM employees&quot;\ncursor.execute(query)\n\nresults = cursor.fetchall()\nfor row in results:\n    print(row[0])\n<\/code><\/pre>\n<p>\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\uff0c\u60a8\u80fd\u591f\u8f7b\u677e\u83b7\u53d6\u6307\u5b9a\u5b57\u6bb5\u7684\u6570\u636e\u3002<\/p>\n<p><strong>\u5728Python\u4e2d\u5982\u4f55\u5904\u7406\u4ece\u6570\u636e\u5e93\u4e2d\u91c7\u96c6\u7684\u6570\u636e\uff1f<\/strong><br \/>\u5728\u83b7\u53d6\u6570\u636e\u540e\uff0c\u901a\u5e38\u9700\u8981\u5bf9\u5176\u8fdb\u884c\u5904\u7406\u3002\u60a8\u53ef\u4ee5\u5c06\u6570\u636e\u5b58\u50a8\u5728Python\u7684\u5217\u8868\u6216\u5b57\u5178\u4e2d\uff0c\u4ee5\u4fbf\u540e\u7eed\u5206\u6790\u548c\u64cd\u4f5c\u3002\u4f8b\u5982\uff0c\u5c06\u7ed3\u679c\u8f6c\u6362\u4e3a\u5b57\u5178\u5f62\u5f0f\u53ef\u4ee5\u5982\u4e0b\u5b9e\u73b0\uff1a<\/p>\n<pre><code class=\"language-python\">employees = []\nfor row in results:\n    employees.append({&#39;name&#39;: row[0]})\n\nprint(employees)\n<\/code><\/pre>\n<p>\u8fd9\u79cd\u7ed3\u6784\u4f7f\u5f97\u6570\u636e\u7684\u8bbf\u95ee\u548c\u64cd\u4f5c\u66f4\u52a0\u65b9\u4fbf\uff0c\u4fbf\u4e8e\u540e\u7eed\u7684\u6570\u636e\u5206\u6790\u6216\u53ef\u89c6\u5316\u5de5\u4f5c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Python\u91c7\u96c6\u6570\u636e\u5e93\u6570\u636e\u7684\u65b9\u6cd5\u5305\u62ec\u4f7f\u7528\u6570\u636e\u5e93\u8fde\u63a5\u5e93\u3001\u6267\u884cSQL\u67e5\u8be2\u3001\u5904\u7406\u548c\u5b58\u50a8\u7ed3\u679c\u3002\u5728\u8fd9\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u4eec\u5c06\u8be6\u7ec6 [&hellip;]","protected":false},"author":3,"featured_media":1031353,"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\/1031350"}],"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=1031350"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1031350\/revisions"}],"predecessor-version":[{"id":1031354,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1031350\/revisions\/1031354"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1031353"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1031350"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1031350"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1031350"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}