{"id":1027752,"date":"2024-12-31T10:53:37","date_gmt":"2024-12-31T02:53:37","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1027752.html"},"modified":"2024-12-31T10:53:39","modified_gmt":"2024-12-31T02:53:39","slug":"python%e5%a6%82%e4%bd%95%e6%8a%8a%e6%8e%a5%e6%94%b6%e5%88%b0%e7%9a%84%e6%95%b0%e6%8d%ae%e5%88%86%e5%bc%80","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1027752.html","title":{"rendered":"python\u5982\u4f55\u628a\u63a5\u6536\u5230\u7684\u6570\u636e\u5206\u5f00"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2024\/12\/7840b11a-324d-4fd5-b75f-a1ef774bc11c.webp?x-oss-process=image\/auto-orient,1\/format,webp\" alt=\"python\u5982\u4f55\u628a\u63a5\u6536\u5230\u7684\u6570\u636e\u5206\u5f00\" \/><\/p>\n<p><p> <strong>Python\u53ef\u4ee5\u4f7f\u7528split()\u3001\u6b63\u5219\u8868\u8fbe\u5f0f\u3001\u5b57\u7b26\u4e32\u5206\u7247\u7b49\u65b9\u6cd5\u5c06\u63a5\u6536\u5230\u7684\u6570\u636e\u5206\u5f00<\/strong>\u3002\u4f7f\u7528\u8fd9\u4e9b\u65b9\u6cd5\u53ef\u4ee5\u6709\u6548\u5730\u89e3\u6790\u548c\u5904\u7406\u6570\u636e\u3002\u4f8b\u5982\uff0c\u4f7f\u7528split()\u65b9\u6cd5\u53ef\u4ee5\u5c06\u4e00\u4e2a\u5b57\u7b26\u4e32\u6309\u6307\u5b9a\u7684\u5206\u9694\u7b26\u62c6\u5206\u6210\u591a\u4e2a\u90e8\u5206\uff0c\u4ece\u800c\u4fbf\u4e8e\u8fdb\u4e00\u6b65\u7684\u6570\u636e\u5904\u7406\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u8fd9\u4e9b\u65b9\u6cd5\u7684\u5177\u4f53\u4f7f\u7528\u65b9\u5f0f\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001split() \u65b9\u6cd5<\/h3>\n<\/p>\n<p><p>split() \u65b9\u6cd5\u662f\u6700\u5e38\u7528\u7684\u5b57\u7b26\u4e32\u5904\u7406\u65b9\u6cd5\u4e4b\u4e00\u3002\u5b83\u6839\u636e\u6307\u5b9a\u7684\u5206\u9694\u7b26\u5c06\u5b57\u7b26\u4e32\u62c6\u5206\u6210\u4e00\u4e2a\u5217\u8868\u3002<\/p>\n<\/p>\n<p><h4>1. \u57fa\u672c\u7528\u6cd5<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">data = &quot;apple,banana,cherry&quot;<\/p>\n<p>fruits = data.split(&#39;,&#39;)<\/p>\n<p>print(fruits)  # \u8f93\u51fa: [&#39;apple&#39;, &#39;banana&#39;, &#39;cherry&#39;]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u5c06\u5b57\u7b26\u4e32 <code>data<\/code> \u6309\u7167\u9017\u53f7\u5206\u9694\u7b26 <code>&#39;,&#39;<\/code> \u62c6\u5206\u6210\u4e09\u4e2a\u5143\u7d20\uff0c\u5f97\u5230\u4e00\u4e2a\u5305\u542b\u8fd9\u4e09\u4e2a\u5143\u7d20\u7684\u5217\u8868 <code>fruits<\/code>\u3002<\/p>\n<\/p>\n<p><h4>2. \u81ea\u5b9a\u4e49\u5206\u9694\u7b26<\/h4>\n<\/p>\n<p><p>split() \u65b9\u6cd5\u4e0d\u4ec5\u9650\u4e8e\u9017\u53f7\uff0c\u8fd8\u53ef\u4ee5\u4f7f\u7528\u5176\u4ed6\u5206\u9694\u7b26\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">data = &quot;apple|banana|cherry&quot;<\/p>\n<p>fruits = data.split(&#39;|&#39;)<\/p>\n<p>print(fruits)  # \u8f93\u51fa: [&#39;apple&#39;, &#39;banana&#39;, &#39;cherry&#39;]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u7ad6\u7ebf <code>|<\/code> \u4f5c\u4e3a\u5206\u9694\u7b26\uff0c\u6548\u679c\u540c\u6837\u9002\u7528\u3002<\/p>\n<\/p>\n<p><h4>3. \u5206\u9694\u7b26\u4e3a\u7a7a\u683c<\/h4>\n<\/p>\n<p><p>\u5f53\u5206\u9694\u7b26\u4e3a\u7a7a\u683c\u65f6\uff0csplit() \u65b9\u6cd5\u4f1a\u81ea\u52a8\u5c06\u591a\u4e2a\u8fde\u7eed\u7684\u7a7a\u683c\u89c6\u4e3a\u4e00\u4e2a\u5206\u9694\u7b26\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">data = &quot;apple  banana   cherry&quot;<\/p>\n<p>fruits = data.split()<\/p>\n<p>print(fruits)  # \u8f93\u51fa: [&#39;apple&#39;, &#39;banana&#39;, &#39;cherry&#39;]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e8c\u3001\u6b63\u5219\u8868\u8fbe\u5f0f<\/h3>\n<\/p>\n<p><p>\u6b63\u5219\u8868\u8fbe\u5f0f\u63d0\u4f9b\u4e86\u66f4\u4e3a\u5f3a\u5927\u7684\u5b57\u7b26\u4e32\u5206\u5272\u529f\u80fd\uff0c\u9002\u7528\u4e8e\u66f4\u590d\u6742\u7684\u5206\u5272\u89c4\u5219\u3002Python \u7684 <code>re<\/code> \u6a21\u5757\u63d0\u4f9b\u4e86 <code>re.split()<\/code> \u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><h4>1. \u57fa\u672c\u7528\u6cd5<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">import re<\/p>\n<p>data = &quot;apple,banana;cherry|date&quot;<\/p>\n<p>fruits = re.split(r&#39;[;,|]&#39;, data)<\/p>\n<p>print(fruits)  # \u8f93\u51fa: [&#39;apple&#39;, &#39;banana&#39;, &#39;cherry&#39;, &#39;date&#39;]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>re.split()<\/code> \u65b9\u6cd5\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f <code>[;,|]<\/code> \u6765\u5339\u914d\u9017\u53f7\u3001\u5206\u53f7\u548c\u7ad6\u7ebf\uff0c\u6700\u7ec8\u5c06\u5b57\u7b26\u4e32\u62c6\u5206\u6210\u56db\u4e2a\u5143\u7d20\u3002<\/p>\n<\/p>\n<p><h4>2. \u66f4\u590d\u6742\u7684\u5206\u5272\u89c4\u5219<\/h4>\n<\/p>\n<p><p>\u6b63\u5219\u8868\u8fbe\u5f0f\u53ef\u4ee5\u5b9a\u4e49\u66f4\u590d\u6742\u7684\u5206\u5272\u89c4\u5219\uff0c\u6bd4\u5982\u6839\u636e\u7279\u5b9a\u6a21\u5f0f\u5206\u5272\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">data = &quot;apple123banana456cherry789date&quot;<\/p>\n<p>fruits = re.split(r&#39;\\d+&#39;, data)<\/p>\n<p>print(fruits)  # \u8f93\u51fa: [&#39;apple&#39;, &#39;banana&#39;, &#39;cherry&#39;, &#39;date&#39;]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f <code>\\d+<\/code> \u6765\u5339\u914d\u4e00\u4e2a\u6216\u591a\u4e2a\u6570\u5b57\uff0c\u5c06\u5b57\u7b26\u4e32\u62c6\u5206\u6210\u56db\u4e2a\u5143\u7d20\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u5b57\u7b26\u4e32\u5206\u7247<\/h3>\n<\/p>\n<p><p>\u5b57\u7b26\u4e32\u5206\u7247\u662f\u4e00\u79cd\u76f4\u63a5\u83b7\u53d6\u5b57\u7b26\u4e32\u7684\u7279\u5b9a\u90e8\u5206\u7684\u65b9\u6cd5\u3002\u5b83\u9002\u7528\u4e8e\u5df2\u77e5\u56fa\u5b9a\u4f4d\u7f6e\u7684\u5b57\u7b26\u4e32\u5206\u5272\u3002<\/p>\n<\/p>\n<p><h4>1. \u57fa\u672c\u7528\u6cd5<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">data = &quot;applebananacherrydate&quot;<\/p>\n<p>apple = data[0:5]<\/p>\n<p>banana = data[5:11]<\/p>\n<p>cherry = data[11:17]<\/p>\n<p>date = data[17:21]<\/p>\n<p>print(apple, banana, cherry, date)  # \u8f93\u51fa: apple banana cherry date<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u901a\u8fc7\u6307\u5b9a\u5b57\u7b26\u4e32\u7684\u8d77\u59cb\u548c\u7ed3\u675f\u4f4d\u7f6e\uff0c\u76f4\u63a5\u83b7\u53d6\u4e86\u6bcf\u4e2a\u90e8\u5206\u3002<\/p>\n<\/p>\n<p><h4>2. \u4f7f\u7528\u6b65\u957f<\/h4>\n<\/p>\n<p><p>\u5b57\u7b26\u4e32\u5206\u7247\u8fd8\u53ef\u4ee5\u4f7f\u7528\u6b65\u957f\u6765\u83b7\u53d6\u7279\u5b9a\u90e8\u5206\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">data = &quot;a1b2c3d4e5f6g7&quot;<\/p>\n<p>letters = data[::2]<\/p>\n<p>numbers = data[1::2]<\/p>\n<p>print(letters)  # \u8f93\u51fa: abcdefg<\/p>\n<p>print(numbers)  # \u8f93\u51fa: 1234567<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u6b65\u957f <code>2<\/code>\uff0c\u5206\u522b\u83b7\u53d6\u4e86\u6240\u6709\u7684\u5b57\u6bcd\u548c\u6570\u5b57\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u4f7f\u7528 csv \u6a21\u5757<\/h3>\n<\/p>\n<p><p>\u5f53\u5904\u7406\u7ed3\u6784\u5316\u6570\u636e\u65f6\uff0c\u7279\u522b\u662f CSV \u6587\u4ef6\uff0c\u53ef\u4ee5\u4f7f\u7528 Python \u7684 <code>csv<\/code> \u6a21\u5757\u3002<\/p>\n<\/p>\n<p><h4>1. \u8bfb\u53d6 CSV \u6587\u4ef6<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">import csv<\/p>\n<p>with open(&#39;data.csv&#39;, newline=&#39;&#39;) as csvfile:<\/p>\n<p>    reader = csv.reader(csvfile, delimiter=&#39;,&#39;)<\/p>\n<p>    for row in reader:<\/p>\n<p>        print(row)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u8bfb\u53d6\u4e86\u4e00\u4e2a CSV \u6587\u4ef6\uff0c\u5e76\u5c06\u6bcf\u4e00\u884c\u5206\u5272\u6210\u5217\u8868\u3002<\/p>\n<\/p>\n<p><h4>2. \u5199\u5165 CSV \u6587\u4ef6<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">import csv<\/p>\n<p>data = [[&#39;apple&#39;, &#39;banana&#39;, &#39;cherry&#39;], [&#39;date&#39;, &#39;fig&#39;, &#39;grape&#39;]]<\/p>\n<p>with open(&#39;output.csv&#39;, &#39;w&#39;, newline=&#39;&#39;) as csvfile:<\/p>\n<p>    writer = csv.writer(csvfile, delimiter=&#39;,&#39;)<\/p>\n<p>    writer.writerows(data)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u5c06\u4e00\u4e2a\u5217\u8868\u5199\u5165\u4e86 CSV \u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001\u4f7f\u7528 pandas<\/h3>\n<\/p>\n<p><p><code>pandas<\/code> \u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u6570\u636e\u5904\u7406\u5e93\uff0c\u9002\u7528\u4e8e\u5904\u7406\u590d\u6742\u7684\u7ed3\u6784\u5316\u6570\u636e\u3002<\/p>\n<\/p>\n<p><h4>1. \u8bfb\u53d6\u6570\u636e<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<p>df = pd.read_csv(&#39;data.csv&#39;)<\/p>\n<p>print(df)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528 <code>pandas<\/code> \u8bfb\u53d6\u4e86\u4e00\u4e2a CSV \u6587\u4ef6\uff0c\u5e76\u5c55\u793a\u4e86\u5176\u5185\u5bb9\u3002<\/p>\n<\/p>\n<p><h4>2. \u6570\u636e\u62c6\u5206<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<p>data = {&#39;fruits&#39;: [&#39;apple,banana,cherry&#39;, &#39;date,fig,grape&#39;]}<\/p>\n<p>df = pd.DataFrame(data)<\/p>\n<p>df[&#39;fruits&#39;] = df[&#39;fruits&#39;].str.split(&#39;,&#39;)<\/p>\n<p>print(df)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u5c06 <code>fruits<\/code> \u5217\u4e2d\u7684\u5b57\u7b26\u4e32\u62c6\u5206\u6210\u5217\u8868\u3002<\/p>\n<\/p>\n<p><h3>\u516d\u3001json \u6a21\u5757<\/h3>\n<\/p>\n<p><p>\u5f53\u5904\u7406 JSON \u683c\u5f0f\u7684\u6570\u636e\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528 Python \u7684 <code>json<\/code> \u6a21\u5757\u3002<\/p>\n<\/p>\n<p><h4>1. \u89e3\u6790 JSON \u6570\u636e<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">import json<\/p>\n<p>data = &#39;{&quot;fruits&quot;: [&quot;apple&quot;, &quot;banana&quot;, &quot;cherry&quot;], &quot;vegetables&quot;: [&quot;carrot&quot;, &quot;broccoli&quot;]}&#39;<\/p>\n<p>parsed_data = json.loads(data)<\/p>\n<p>print(parsed_data)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u89e3\u6790\u4e86\u4e00\u4e2a JSON \u5b57\u7b26\u4e32\uff0c\u5e76\u5c06\u5176\u8f6c\u6362\u6210\u4e86\u5b57\u5178\u3002<\/p>\n<\/p>\n<p><h4>2. \u751f\u6210 JSON \u6570\u636e<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">import json<\/p>\n<p>data = {<\/p>\n<p>    &#39;fruits&#39;: [&#39;apple&#39;, &#39;banana&#39;, &#39;cherry&#39;],<\/p>\n<p>    &#39;vegetables&#39;: [&#39;carrot&#39;, &#39;broccoli&#39;]<\/p>\n<p>}<\/p>\n<p>json_data = json.dumps(data)<\/p>\n<p>print(json_data)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u5c06\u4e00\u4e2a\u5b57\u5178\u8f6c\u6362\u6210\u4e86 JSON \u5b57\u7b26\u4e32\u3002<\/p>\n<\/p>\n<p><h3>\u4e03\u3001\u7ed3\u5408\u591a\u79cd\u65b9\u6cd5<\/h3>\n<\/p>\n<p><p>\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u7ecf\u5e38\u9700\u8981\u7ed3\u5408\u591a\u79cd\u65b9\u6cd5\u6765\u5904\u7406\u590d\u6742\u7684\u6570\u636e\u3002<\/p>\n<\/p>\n<p><h4>1. \u793a\u4f8b<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">import re<\/p>\n<p>import json<\/p>\n<p>data = &#39;{&quot;info&quot;: &quot;apple,banana;cherry|date&quot;}&#39;<\/p>\n<p>parsed_data = json.loads(data)<\/p>\n<p>fruits = re.split(r&#39;[;,|]&#39;, parsed_data[&#39;info&#39;])<\/p>\n<p>print(fruits)  # \u8f93\u51fa: [&#39;apple&#39;, &#39;banana&#39;, &#39;cherry&#39;, &#39;date&#39;]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u9996\u5148\u89e3\u6790 JSON \u6570\u636e\uff0c\u7136\u540e\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u62c6\u5206\u5b57\u7b26\u4e32\u3002<\/p>\n<\/p>\n<p><h3>\u516b\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>Python \u63d0\u4f9b\u4e86\u591a\u79cd\u65b9\u6cd5\u6765\u5206\u5272\u63a5\u6536\u5230\u7684\u6570\u636e\uff0c\u5305\u62ec <strong>split() \u65b9\u6cd5\u3001\u6b63\u5219\u8868\u8fbe\u5f0f\u3001\u5b57\u7b26\u4e32\u5206\u7247\u3001csv \u6a21\u5757\u3001pandas \u5e93\u548c json \u6a21\u5757<\/strong>\u3002\u6839\u636e\u5b9e\u9645\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\uff0c\u53ef\u4ee5\u9ad8\u6548\u5730\u5904\u7406\u548c\u89e3\u6790\u6570\u636e\u3002\u901a\u8fc7\u7ed3\u5408\u591a\u79cd\u65b9\u6cd5\uff0c\u53ef\u4ee5\u5e94\u5bf9\u590d\u6742\u7684\u6570\u636e\u5904\u7406\u573a\u666f\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u5206\u9694\u5b57\u7b26\u4e32\u6570\u636e\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u591a\u79cd\u65b9\u6cd5\u6765\u5206\u9694\u5b57\u7b26\u4e32\uff0c\u4f8b\u5982\u4f7f\u7528<code>split()<\/code>\u65b9\u6cd5\u3002\u8be5\u65b9\u6cd5\u5141\u8bb8\u60a8\u6307\u5b9a\u4e00\u4e2a\u5206\u9694\u7b26\uff0c\u6839\u636e\u8be5\u5206\u9694\u7b26\u5c06\u5b57\u7b26\u4e32\u62c6\u5206\u4e3a\u591a\u4e2a\u90e8\u5206\u3002\u4f8b\u5982\uff0c\u5982\u679c\u60a8\u6709\u4e00\u4e2a\u4ee5\u9017\u53f7\u5206\u9694\u7684\u5b57\u7b26\u4e32\uff0c\u53ef\u4ee5\u4f7f\u7528<code>data.split(&#39;,&#39;)<\/code>\u5c06\u5176\u8f6c\u6362\u4e3a\u5217\u8868\u3002<\/p>\n<p><strong>Python\u5982\u4f55\u5904\u7406\u63a5\u6536\u5230\u7684\u4e8c\u8fdb\u5236\u6570\u636e\uff1f<\/strong><br \/>\u5904\u7406\u4e8c\u8fdb\u5236\u6570\u636e\u65f6\uff0c\u901a\u5e38\u9700\u8981\u4f7f\u7528<code>bytes<\/code>\u7c7b\u578b\u3002\u53ef\u4ee5\u901a\u8fc7<code>struct<\/code>\u6a21\u5757\u5c06\u4e8c\u8fdb\u5236\u6570\u636e\u8f6c\u6362\u4e3a\u66f4\u6613\u4e8e\u64cd\u4f5c\u7684\u683c\u5f0f\uff0c\u6216\u8005\u4f7f\u7528<code>decode()<\/code>\u65b9\u6cd5\u5c06\u5176\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\u3002\u91cd\u8981\u7684\u662f\u8981\u786e\u4fdd\u77e5\u9053\u6570\u636e\u7684\u683c\u5f0f\uff0c\u4ee5\u4fbf\u6b63\u786e\u89e3\u6790\u3002<\/p>\n<p><strong>\u5728Python\u4e2d\u5982\u4f55\u8bfb\u53d6\u548c\u5206\u9694JSON\u6570\u636e\uff1f<\/strong><br \/>\u8bfb\u53d6JSON\u6570\u636e\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528<code>json<\/code>\u6a21\u5757\u7684<code>loads()<\/code>\u6216<code>load()<\/code>\u65b9\u6cd5\u5c06\u6570\u636e\u8f6c\u6362\u4e3aPython\u5b57\u5178\u3002\u4e4b\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u5b57\u5178\u7684\u952e\u8bbf\u95ee\u7279\u5b9a\u7684\u6570\u636e\u90e8\u5206\u3002\u8fd9\u79cd\u65b9\u5f0f\u4e0d\u4ec5\u9ad8\u6548\uff0c\u8fd8\u80fd\u65b9\u4fbf\u5730\u8fdb\u884c\u6570\u636e\u64cd\u4f5c\u548c\u5206\u6790\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Python\u53ef\u4ee5\u4f7f\u7528split()\u3001\u6b63\u5219\u8868\u8fbe\u5f0f\u3001\u5b57\u7b26\u4e32\u5206\u7247\u7b49\u65b9\u6cd5\u5c06\u63a5\u6536\u5230\u7684\u6570\u636e\u5206\u5f00\u3002\u4f7f\u7528\u8fd9\u4e9b\u65b9\u6cd5\u53ef\u4ee5\u6709\u6548\u5730\u89e3\u6790 [&hellip;]","protected":false},"author":3,"featured_media":1027767,"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\/1027752"}],"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=1027752"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1027752\/revisions"}],"predecessor-version":[{"id":1027770,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1027752\/revisions\/1027770"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1027767"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1027752"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1027752"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1027752"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}