{"id":1121856,"date":"2025-01-08T19:14:10","date_gmt":"2025-01-08T11:14:10","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1121856.html"},"modified":"2025-01-08T19:14:15","modified_gmt":"2025-01-08T11:14:15","slug":"%e5%a6%82%e4%bd%95%e7%94%a8%e6%96%87%e4%bb%b6%e5%af%bc%e5%85%a5%e6%88%90python%e7%9a%84%e5%ad%97%e5%85%b8%e6%95%b0%e7%bb%84","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1121856.html","title":{"rendered":"\u5982\u4f55\u7528\u6587\u4ef6\u5bfc\u5165\u6210Python\u7684\u5b57\u5178\u6570\u7ec4"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25083931\/9511cd6e-effe-4c6b-871b-85c619760a4c.webp\" alt=\"\u5982\u4f55\u7528\u6587\u4ef6\u5bfc\u5165\u6210Python\u7684\u5b57\u5178\u6570\u7ec4\" \/><\/p>\n<p><p> <strong>\u5982\u4f55\u7528\u6587\u4ef6\u5bfc\u5165\u6210Python\u7684\u5b57\u5178\u6570\u7ec4<\/strong><\/p>\n<\/p>\n<p><p>\u5728Python\u7f16\u7a0b\u4e2d\uff0c<strong>\u4f7f\u7528\u6587\u4ef6\u5bfc\u5165\u6210\u5b57\u5178\u6570\u7ec4\u7684\u65b9\u6cd5\u5305\u62ec\uff1a\u8bfb\u53d6\u6587\u4ef6\u5185\u5bb9\u3001\u89e3\u6790\u6587\u4ef6\u683c\u5f0f\u3001\u8f6c\u6362\u6570\u636e\u7c7b\u578b<\/strong>\u3002\u6700\u5e38\u89c1\u7684\u6587\u4ef6\u683c\u5f0f\u6709JSON\u3001CSV\u548c\u6587\u672c\u6587\u4ef6\u3002\u6211\u4eec\u5c06\u8be6\u7ec6\u8ba8\u8bba\u5982\u4f55\u4f7f\u7528\u8fd9\u4e9b\u6587\u4ef6\u683c\u5f0f\u5bfc\u5165\u6570\u636e\uff0c\u5e76\u5c06\u5176\u8f6c\u6362\u4e3aPython\u7684\u5b57\u5178\u6570\u7ec4\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u8bfb\u53d6\u6587\u4ef6\u5185\u5bb9<\/h3>\n<\/p>\n<p><h4>1. \u4f7f\u7528Python\u5185\u7f6e\u7684<code>open()<\/code>\u51fd\u6570<\/h4>\n<\/p>\n<p><p>\u65e0\u8bba\u6587\u4ef6\u683c\u5f0f\u5982\u4f55\uff0c\u7b2c\u4e00\u6b65\u662f\u8bfb\u53d6\u6587\u4ef6\u5185\u5bb9\u3002Python\u63d0\u4f9b\u4e86\u5185\u7f6e\u7684<code>open()<\/code>\u51fd\u6570\u6765\u5904\u7406\u6587\u4ef6\u8bfb\u53d6\u64cd\u4f5c\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def read_file(file_path):<\/p>\n<p>    with open(file_path, &#39;r&#39;) as file:<\/p>\n<p>        content = file.read()<\/p>\n<p>    return content<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4f7f\u7528<code>with open()<\/code>\u53ef\u4ee5\u786e\u4fdd\u6587\u4ef6\u5728\u64cd\u4f5c\u5b8c\u6210\u540e\u88ab\u6b63\u786e\u5173\u95ed\uff0c\u907f\u514d\u8d44\u6e90\u6cc4\u9732\u3002<\/p>\n<\/p>\n<p><h4>2. \u8bfb\u53d6JSON\u6587\u4ef6<\/h4>\n<\/p>\n<p><p>JSON\u6587\u4ef6\u5728\u6570\u636e\u4ea4\u6362\u4e2d\u975e\u5e38\u6d41\u884c\uff0c\u56e0\u4e3a\u5b83\u4eec\u7ed3\u6784\u5316\u4e14\u6613\u4e8e\u89e3\u6790\u3002Python\u7684<code>json<\/code>\u6a21\u5757\u53ef\u4ee5\u8f7b\u677e\u5904\u7406JSON\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import json<\/p>\n<p>def read_json(file_path):<\/p>\n<p>    with open(file_path, &#39;r&#39;) as file:<\/p>\n<p>        data = json.load(file)<\/p>\n<p>    return data<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3. \u8bfb\u53d6CSV\u6587\u4ef6<\/h4>\n<\/p>\n<p><p>CSV\u6587\u4ef6\u5e38\u7528\u4e8e\u5b58\u50a8\u8868\u683c\u6570\u636e\u3002Python\u7684<code>csv<\/code>\u6a21\u5757\u53ef\u4ee5\u5e2e\u52a9\u89e3\u6790CSV\u6587\u4ef6\uff0c\u5e76\u5c06\u5176\u8f6c\u6362\u4e3a\u5b57\u5178\u6570\u7ec4\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import csv<\/p>\n<p>def read_csv(file_path):<\/p>\n<p>    with open(file_path, &#39;r&#39;) as file:<\/p>\n<p>        reader = csv.DictReader(file)<\/p>\n<p>        data = [row for row in reader]<\/p>\n<p>    return data<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e8c\u3001\u89e3\u6790\u6587\u4ef6\u683c\u5f0f<\/h3>\n<\/p>\n<p><p>\u5728\u8bfb\u53d6\u6587\u4ef6\u5185\u5bb9\u540e\uff0c\u9700\u8981\u89e3\u6790\u6587\u4ef6\u683c\u5f0f\uff0c\u4ee5\u4fbf\u5c06\u6570\u636e\u8f6c\u6362\u4e3a\u5b57\u5178\u6570\u7ec4\u3002<\/p>\n<\/p>\n<p><h4>1. JSON\u683c\u5f0f<\/h4>\n<\/p>\n<p><p>JSON\u683c\u5f0f\u6570\u636e\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528<code>json.load()<\/code>\u65b9\u6cd5\u89e3\u6790\u4e3a\u5b57\u5178\u6570\u7ec4\u3002JSON\u6587\u4ef6\u901a\u5e38\u5305\u542b\u4e00\u4e2a\u5217\u8868\uff0c\u6bcf\u4e2a\u5217\u8868\u9879\u662f\u4e00\u4e2a\u5b57\u5178\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import json<\/p>\n<p>def parse_json(content):<\/p>\n<p>    return json.loads(content)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. CSV\u683c\u5f0f<\/h4>\n<\/p>\n<p><p>CSV\u683c\u5f0f\u6570\u636e\u9700\u8981\u4f7f\u7528<code>csv.DictReader<\/code>\u89e3\u6790\u3002<code>DictReader<\/code>\u4f1a\u5c06\u6bcf\u4e00\u884c\u6570\u636e\u8f6c\u6362\u4e3a\u5b57\u5178\uff0c\u5e76\u5c06\u5176\u6dfb\u52a0\u5230\u4e00\u4e2a\u5217\u8868\u4e2d\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import csv<\/p>\n<p>def parse_csv(content):<\/p>\n<p>    reader = csv.DictReader(content.splitlines())<\/p>\n<p>    return [row for row in reader]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3. \u81ea\u5b9a\u4e49\u6587\u672c\u683c\u5f0f<\/h4>\n<\/p>\n<p><p>\u5bf9\u4e8e\u81ea\u5b9a\u4e49\u683c\u5f0f\u7684\u6587\u672c\u6587\u4ef6\uff0c\u9700\u8981\u7f16\u5199\u81ea\u5b9a\u4e49\u89e3\u6790\u903b\u8f91\u3002\u4f8b\u5982\uff0c\u5047\u8bbe\u6587\u672c\u6587\u4ef6\u4e2d\u6bcf\u4e00\u884c\u4ee3\u8868\u4e00\u4e2a\u5b57\u5178\u7684\u952e\u503c\u5bf9\uff0c\u952e\u548c\u503c\u4e4b\u95f4\u4f7f\u7528\u5192\u53f7\u5206\u9694\uff0c\u6bcf\u4e2a\u5b57\u5178\u4e4b\u95f4\u4f7f\u7528\u7a7a\u884c\u5206\u9694\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def parse_custom_text(content):<\/p>\n<p>    data = []<\/p>\n<p>    current_dict = {}<\/p>\n<p>    for line in content.splitlines():<\/p>\n<p>        if line.strip() == &quot;&quot;:<\/p>\n<p>            if current_dict:<\/p>\n<p>                data.append(current_dict)<\/p>\n<p>                current_dict = {}<\/p>\n<p>        else:<\/p>\n<p>            key, value = line.split(&quot;:&quot;)<\/p>\n<p>            current_dict[key.strip()] = value.strip()<\/p>\n<p>    if current_dict:<\/p>\n<p>        data.append(current_dict)<\/p>\n<p>    return data<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e09\u3001\u8f6c\u6362\u6570\u636e\u7c7b\u578b<\/h3>\n<\/p>\n<p><p>\u5728\u89e3\u6790\u6587\u4ef6\u683c\u5f0f\u540e\uff0c\u9700\u8981\u5c06\u6570\u636e\u8f6c\u6362\u4e3aPython\u7684\u5b57\u5178\u6570\u7ec4\u3002<\/p>\n<\/p>\n<p><h4>1. JSON\u6570\u636e\u8f6c\u6362<\/h4>\n<\/p>\n<p><p>\u7531\u4e8e<code>json.load()<\/code>\u65b9\u6cd5\u5df2\u7ecf\u5c06\u6570\u636e\u8f6c\u6362\u4e3a\u5b57\u5178\u6570\u7ec4\uff0c\u56e0\u6b64\u4e0d\u9700\u8981\u989d\u5916\u7684\u8f6c\u6362\u6b65\u9aa4\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">data = parse_json(content)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. CSV\u6570\u636e\u8f6c\u6362<\/h4>\n<\/p>\n<p><p>\u540c\u6837\uff0c<code>csv.DictReader<\/code>\u65b9\u6cd5\u5df2\u7ecf\u5c06\u6bcf\u4e00\u884c\u6570\u636e\u8f6c\u6362\u4e3a\u5b57\u5178\uff0c\u5e76\u5c06\u5176\u6dfb\u52a0\u5230\u5217\u8868\u4e2d\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">data = parse_csv(content)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3. \u81ea\u5b9a\u4e49\u6587\u672c\u6570\u636e\u8f6c\u6362<\/h4>\n<\/p>\n<p><p>\u81ea\u5b9a\u4e49\u6587\u672c\u6570\u636e\u89e3\u6790\u540e\uff0c\u4e5f\u76f4\u63a5\u5f97\u5230\u5b57\u5178\u6570\u7ec4\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">data = parse_custom_text(content)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u56db\u3001\u5904\u7406\u5f02\u5e38\u60c5\u51b5<\/h3>\n<\/p>\n<p><p>\u5728\u5b9e\u9645\u64cd\u4f5c\u4e2d\uff0c\u6587\u4ef6\u8bfb\u53d6\u548c\u89e3\u6790\u8fc7\u7a0b\u4e2d\u53ef\u80fd\u4f1a\u51fa\u73b0\u5f02\u5e38\u60c5\u51b5\uff0c\u9700\u8981\u8fdb\u884c\u5f02\u5e38\u5904\u7406\u3002<\/p>\n<\/p>\n<p><h4>1. \u6587\u4ef6\u4e0d\u5b58\u5728<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528<code>try...except<\/code>\u5757\u6355\u83b7<code>FileNotFoundError<\/code>\u5f02\u5e38\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">try:<\/p>\n<p>    content = read_file(file_path)<\/p>\n<p>except FileNotFoundError:<\/p>\n<p>    print(f&quot;File {file_path} not found.&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. JSON\u89e3\u6790\u9519\u8bef<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528<code>try...except<\/code>\u5757\u6355\u83b7<code>json.JSONDecodeError<\/code>\u5f02\u5e38\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">try:<\/p>\n<p>    data = parse_json(content)<\/p>\n<p>except json.JSONDecodeError:<\/p>\n<p>    print(f&quot;Error decoding JSON from file {file_path}.&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3. CSV\u89e3\u6790\u9519\u8bef<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528<code>try...except<\/code>\u5757\u6355\u83b7<code>csv.Error<\/code>\u5f02\u5e38\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">try:<\/p>\n<p>    data = parse_csv(content)<\/p>\n<p>except csv.Error:<\/p>\n<p>    print(f&quot;Error parsing CSV from file {file_path}.&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e94\u3001\u7efc\u5408\u793a\u4f8b<\/h3>\n<\/p>\n<p><p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7efc\u5408\u793a\u4f8b\uff0c\u5c55\u793a\u5982\u4f55\u8bfb\u53d6\u4e0d\u540c\u683c\u5f0f\u7684\u6587\u4ef6\uff0c\u5e76\u5c06\u5176\u8f6c\u6362\u4e3a\u5b57\u5178\u6570\u7ec4\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import json<\/p>\n<p>import csv<\/p>\n<p>def read_file(file_path):<\/p>\n<p>    with open(file_path, &#39;r&#39;) as file:<\/p>\n<p>        content = file.read()<\/p>\n<p>    return content<\/p>\n<p>def parse_json(content):<\/p>\n<p>    return json.loads(content)<\/p>\n<p>def parse_csv(content):<\/p>\n<p>    reader = csv.DictReader(content.splitlines())<\/p>\n<p>    return [row for row in reader]<\/p>\n<p>def parse_custom_text(content):<\/p>\n<p>    data = []<\/p>\n<p>    current_dict = {}<\/p>\n<p>    for line in content.splitlines():<\/p>\n<p>        if line.strip() == &quot;&quot;:<\/p>\n<p>            if current_dict:<\/p>\n<p>                data.append(current_dict)<\/p>\n<p>                current_dict = {}<\/p>\n<p>        else:<\/p>\n<p>            key, value = line.split(&quot;:&quot;)<\/p>\n<p>            current_dict[key.strip()] = value.strip()<\/p>\n<p>    if current_dict:<\/p>\n<p>        data.append(current_dict)<\/p>\n<p>    return data<\/p>\n<p>def convert_file_to_dict_array(file_path, file_type):<\/p>\n<p>    content = read_file(file_path)<\/p>\n<p>    if file_type == &#39;json&#39;:<\/p>\n<p>        return parse_json(content)<\/p>\n<p>    elif file_type == &#39;csv&#39;:<\/p>\n<p>        return parse_csv(content)<\/p>\n<p>    elif file_type == &#39;custom&#39;:<\/p>\n<p>        return parse_custom_text(content)<\/p>\n<p>    else:<\/p>\n<p>        r<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>se ValueError(&quot;Unsupported file type&quot;)<\/p>\n<h2><strong>\u793a\u4f8b\u7528\u6cd5<\/strong><\/h2>\n<p>try:<\/p>\n<p>    data = convert_file_to_dict_array(&#39;data.json&#39;, &#39;json&#39;)<\/p>\n<p>    print(data)<\/p>\n<p>except (FileNotFoundError, json.JSONDecodeError, csv.Error, ValueError) as e:<\/p>\n<p>    print(f&quot;An error occurred: {e}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u4e0a\u8ff0\u6b65\u9aa4\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4e0d\u540c\u683c\u5f0f\u7684\u6587\u4ef6\u5bfc\u5165\u6570\u636e\u5e76\u5c06\u5176\u8f6c\u6362\u4e3aPython\u7684\u5b57\u5178\u6570\u7ec4\u3002\u8fd9\u79cd\u65b9\u6cd5\u53ef\u4ee5\u5e2e\u52a9\u60a8\u5728\u5904\u7406\u6570\u636e\u65f6\u66f4\u52a0\u7075\u6d3b\u548c\u9ad8\u6548\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5c06\u6587\u4ef6\u4e2d\u7684\u6570\u636e\u8f6c\u6362\u4e3aPython\u5b57\u5178\u6570\u7ec4\uff1f<\/strong><br \/>\u8981\u5c06\u6587\u4ef6\u4e2d\u7684\u6570\u636e\u5bfc\u5165\u4e3aPython\u5b57\u5178\u6570\u7ec4\uff0c\u901a\u5e38\u53ef\u4ee5\u4f7f\u7528CSV\u3001JSON\u6216\u6587\u672c\u6587\u4ef6\u7b49\u683c\u5f0f\u3002\u9996\u5148\uff0c\u786e\u4fdd\u6587\u4ef6\u683c\u5f0f\u7b26\u5408\u8981\u6c42\u3002\u5bf9\u4e8eCSV\u6587\u4ef6\uff0c\u53ef\u4ee5\u4f7f\u7528Python\u7684<code>csv<\/code>\u6a21\u5757\u8bfb\u53d6\u6570\u636e\uff0c\u5e76\u5c06\u6bcf\u4e00\u884c\u8f6c\u6362\u4e3a\u5b57\u5178\u3002\u5bf9\u4e8eJSON\u6587\u4ef6\uff0c\u53ef\u4ee5\u4f7f\u7528<code>json<\/code>\u6a21\u5757\u76f4\u63a5\u5c06\u6587\u4ef6\u5185\u5bb9\u89e3\u6790\u4e3a\u5b57\u5178\u6570\u7ec4\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff1a  <\/p>\n<pre><code class=\"language-python\">import json\n\nwith open(&#39;data.json&#39;) as f:\n    data = json.load(f)\n<\/code><\/pre>\n<p><strong>\u652f\u6301\u54ea\u4e9b\u6587\u4ef6\u683c\u5f0f\u53ef\u4ee5\u5bfc\u5165\u4e3a\u5b57\u5178\u6570\u7ec4\uff1f<\/strong><br \/>Python\u652f\u6301\u591a\u79cd\u6587\u4ef6\u683c\u5f0f\u7684\u5bfc\u5165\uff0c\u5305\u62ecCSV\u3001JSON\u3001TXT\u7b49\u3002\u6bcf\u79cd\u683c\u5f0f\u90fd\u6709\u4e0d\u540c\u7684\u89e3\u6790\u65b9\u6cd5\u3002\u5bf9\u4e8eCSV\u6587\u4ef6\uff0c\u53ef\u4ee5\u4f7f\u7528<code>csv.reader<\/code>\u6216<code>pandas<\/code>\u5e93\u8fdb\u884c\u5904\u7406\uff1b\u5bf9\u4e8eJSON\u6587\u4ef6\uff0c\u4f7f\u7528<code>json<\/code>\u5e93\u662f\u6700\u5e38\u89c1\u7684\u65b9\u5f0f\uff1b\u5bf9\u4e8eTXT\u6587\u4ef6\uff0c\u901a\u5e38\u9700\u8981\u901a\u8fc7\u5206\u9694\u7b26\u624b\u52a8\u89e3\u6790\u6570\u636e\u3002<\/p>\n<p><strong>\u5982\u4f55\u5904\u7406\u5bfc\u5165\u8fc7\u7a0b\u4e2d\u53ef\u80fd\u51fa\u73b0\u7684\u9519\u8bef\uff1f<\/strong><br \/>\u5728\u5bfc\u5165\u6587\u4ef6\u65f6\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u683c\u5f0f\u4e0d\u6b63\u786e\u3001\u6587\u4ef6\u4e0d\u5b58\u5728\u6216\u6570\u636e\u7f3a\u5931\u7b49\u95ee\u9898\u3002\u5efa\u8bae\u4f7f\u7528<code>try-except<\/code>\u5757\u6765\u6355\u83b7\u548c\u5904\u7406\u5f02\u5e38\u3002\u4f8b\u5982\uff0c\u5c1d\u8bd5\u8bfb\u53d6\u6587\u4ef6\u65f6\uff0c\u5982\u679c\u6587\u4ef6\u4e0d\u5b58\u5728\uff0c\u53ef\u4ee5\u7ed9\u51fa\u53cb\u597d\u7684\u63d0\u793a\uff0c\u6216\u8005\u5728\u6570\u636e\u89e3\u6790\u65f6\uff0c\u5982\u679c\u53d1\u751f\u9519\u8bef\uff0c\u53ef\u4ee5\u8bb0\u5f55\u95ee\u9898\u5e76\u8df3\u8fc7\u8be5\u6761\u6570\u636e\u3002\u8fd9\u6837\u53ef\u4ee5\u786e\u4fdd\u7a0b\u5e8f\u7684\u5065\u58ee\u6027\u3002  <\/p>\n<pre><code class=\"language-python\">try:\n    with open(&#39;data.json&#39;) as f:\n        data = json.load(f)\nexcept FileNotFoundError:\n    print(&quot;\u6587\u4ef6\u672a\u627e\u5230\uff0c\u8bf7\u68c0\u67e5\u6587\u4ef6\u8def\u5f84\u3002&quot;)\nexcept json.JSONDecodeError:\n    print(&quot;\u6587\u4ef6\u683c\u5f0f\u9519\u8bef\uff0c\u8bf7\u786e\u8ba4\u6587\u4ef6\u662f\u6709\u6548\u7684JSON\u683c\u5f0f\u3002&quot;)\n<\/code><\/pre>\n<p><strong>\u5982\u4f55\u786e\u4fdd\u5bfc\u5165\u7684\u5b57\u5178\u6570\u7ec4\u7b26\u5408\u9884\u671f\u7ed3\u6784\uff1f<\/strong><br \/>\u5728\u5bfc\u5165\u6570\u636e\u540e\uff0c\u8fdb\u884c\u6570\u636e\u9a8c\u8bc1\u662f\u5f88\u91cd\u8981\u7684\u3002\u53ef\u4ee5\u901a\u8fc7\u68c0\u67e5\u5b57\u5178\u7684\u952e\u662f\u5426\u7b26\u5408\u9884\u671f\u6765\u786e\u4fdd\u6570\u636e\u7684\u7ed3\u6784\u6b63\u786e\u3002\u6b64\u5916\uff0c\u53ef\u4ee5\u4f7f\u7528Pandas\u5e93\u7684<code>DataFrame<\/code>\u6765\u8f85\u52a9\u9a8c\u8bc1\u6570\u636e\u7c7b\u578b\u548c\u7ed3\u6784\uff0c\u4ece\u800c\u4f7f\u6570\u636e\u5904\u7406\u66f4\u52a0\u7075\u6d3b\u548c\u9ad8\u6548\u3002\u5bf9\u4e8e\u6bcf\u4e2a\u5b57\u5178\u5143\u7d20\uff0c\u53ef\u4ee5\u4f7f\u7528\u6761\u4ef6\u8bed\u53e5\u6765\u9a8c\u8bc1\u6bcf\u4e2a\u5b57\u6bb5\u7684\u6709\u6548\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5982\u4f55\u7528\u6587\u4ef6\u5bfc\u5165\u6210Python\u7684\u5b57\u5178\u6570\u7ec4 \u5728Python\u7f16\u7a0b\u4e2d\uff0c\u4f7f\u7528\u6587\u4ef6\u5bfc\u5165\u6210\u5b57\u5178\u6570\u7ec4\u7684\u65b9\u6cd5\u5305\u62ec\uff1a\u8bfb\u53d6\u6587\u4ef6\u5185\u5bb9\u3001 [&hellip;]","protected":false},"author":3,"featured_media":1121865,"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\/1121856"}],"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=1121856"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1121856\/revisions"}],"predecessor-version":[{"id":1121867,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1121856\/revisions\/1121867"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1121865"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1121856"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1121856"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1121856"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}