{"id":1136464,"date":"2025-01-08T21:36:11","date_gmt":"2025-01-08T13:36:11","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1136464.html"},"modified":"2025-01-08T21:36:14","modified_gmt":"2025-01-08T13:36:14","slug":"python%e5%a6%82%e4%bd%95%e5%b0%86%e5%ad%97%e7%ac%a6%e4%b8%b2%e8%bd%ac%e6%8d%a2%e6%88%90%e5%88%97%e8%a1%a8","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1136464.html","title":{"rendered":"python\u5982\u4f55\u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u6210\u5217\u8868"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25100558\/16d26a7a-da30-49ec-a11f-4fa17db6d5bf.webp\" alt=\"python\u5982\u4f55\u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u6210\u5217\u8868\" \/><\/p>\n<p><p> <strong>\u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u6210\u5217\u8868\u5728Python\u4e2d\u53ef\u4ee5\u4f7f\u7528\u591a\u79cd\u65b9\u6cd5\uff0c\u4e3b\u8981\u65b9\u6cd5\u5305\u62ec\uff1a\u4f7f\u7528<code>split()<\/code>\u65b9\u6cd5\u3001\u4f7f\u7528<code>list()<\/code>\u6784\u9020\u51fd\u6570\u3001\u4f7f\u7528\u5217\u8868\u63a8\u5bfc\u5f0f\u3001\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u7b49\u3002<\/strong> \u5176\u4e2d\uff0c\u6700\u5e38\u7528\u7684\u65b9\u6cd5\u662f\u4f7f\u7528<code>split()<\/code>\u65b9\u6cd5\uff0c\u56e0\u4e3a\u5b83\u53ef\u4ee5\u6839\u636e\u6307\u5b9a\u7684\u5206\u9694\u7b26\u5c06\u5b57\u7b26\u4e32\u62c6\u5206\u6210\u5217\u8868\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u63cf\u8ff0\u8fd9\u4e9b\u65b9\u6cd5\u4e2d\u7684\u4e00\u79cd\u2014\u2014\u4f7f\u7528<code>split()<\/code>\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><p>Python\u7684<code>split()<\/code>\u65b9\u6cd5\u662f\u4e00\u79cd\u975e\u5e38\u7075\u6d3b\u4e14\u5f3a\u5927\u7684\u5de5\u5177\uff0c\u5b83\u53ef\u4ee5\u5c06\u5b57\u7b26\u4e32\u6839\u636e\u6307\u5b9a\u7684\u5206\u9694\u7b26\u62c6\u5206\u6210\u591a\u4e2a\u5b50\u5b57\u7b26\u4e32\uff0c\u5e76\u8fd4\u56de\u4e00\u4e2a\u5305\u542b\u8fd9\u4e9b\u5b50\u5b57\u7b26\u4e32\u7684\u5217\u8868\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<code>split()<\/code>\u65b9\u6cd5\u4f1a\u4f7f\u7528\u7a7a\u683c\u4f5c\u4e3a\u5206\u9694\u7b26\uff0c\u4f46\u4f60\u4e5f\u53ef\u4ee5\u6307\u5b9a\u5176\u4ed6\u5b57\u7b26\u6216\u5b57\u7b26\u4e32\u4f5c\u4e3a\u5206\u9694\u7b26\u3002\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\uff0c\u4f60\u53ef\u4ee5\u975e\u5e38\u65b9\u4fbf\u5730\u5c06\u4e00\u4e2a\u957f\u5b57\u7b26\u4e32\u8f6c\u6362\u6210\u4e00\u4e2a\u5217\u8868\uff0c\u8fd9\u5bf9\u4e8e\u6570\u636e\u5904\u7406\u548c\u5206\u6790\u975e\u5e38\u6709\u7528\u3002<\/p>\n<\/p>\n<hr>\n<p><h2>\u4e00\u3001\u4f7f\u7528split()\u65b9\u6cd5<\/h2>\n<\/p>\n<p><h3>1\u3001\u57fa\u672c\u7528\u6cd5<\/h3>\n<\/p>\n<p><p><code>split()<\/code>\u65b9\u6cd5\u662fPython\u5185\u7f6e\u7684\u5b57\u7b26\u4e32\u5904\u7406\u51fd\u6570\uff0c\u53ef\u4ee5\u6839\u636e\u6307\u5b9a\u7684\u5206\u9694\u7b26\u5c06\u5b57\u7b26\u4e32\u62c6\u5206\u6210\u591a\u4e2a\u5b50\u5b57\u7b26\u4e32\uff0c\u5e76\u5c06\u8fd9\u4e9b\u5b50\u5b57\u7b26\u4e32\u5b58\u50a8\u5728\u4e00\u4e2a\u5217\u8868\u4e2d\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">text = &quot;Python is a versatile programming language&quot;<\/p>\n<p>word_list = text.split()<\/p>\n<p>print(word_list)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c<code>split()<\/code>\u65b9\u6cd5\u9ed8\u8ba4\u4f7f\u7528\u7a7a\u683c\u4f5c\u4e3a\u5206\u9694\u7b26\uff0c\u5c06\u5b57\u7b26\u4e32<code>text<\/code>\u62c6\u5206\u6210\u591a\u4e2a\u5355\u8bcd\uff0c\u5e76\u5c06\u8fd9\u4e9b\u5355\u8bcd\u5b58\u50a8\u5728\u5217\u8868<code>word_list<\/code>\u4e2d\u3002\u8f93\u51fa\u5c06\u662f\uff1a<\/p>\n<\/p>\n<p><pre><code>[&#39;Python&#39;, &#39;is&#39;, &#39;a&#39;, &#39;versatile&#39;, &#39;programming&#39;, &#39;language&#39;]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2\u3001\u6307\u5b9a\u5206\u9694\u7b26<\/h3>\n<\/p>\n<p><p>\u4f60\u4e5f\u53ef\u4ee5\u6307\u5b9a\u5176\u4ed6\u5b57\u7b26\u6216\u5b57\u7b26\u4e32\u4f5c\u4e3a\u5206\u9694\u7b26\u3002\u4f8b\u5982\uff0c\u5982\u679c\u4f60\u6709\u4e00\u4e2a\u9017\u53f7\u5206\u9694\u7684\u5b57\u7b26\u4e32\uff0c\u4f60\u53ef\u4ee5\u8fd9\u6837\u505a\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">text = &quot;apple,banana,cherry,date&quot;<\/p>\n<p>fruit_list = text.split(&#39;,&#39;)<\/p>\n<p>print(fruit_list)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8f93\u51fa\u5c06\u662f\uff1a<\/p>\n<\/p>\n<p><pre><code>[&#39;apple&#39;, &#39;banana&#39;, &#39;cherry&#39;, &#39;date&#39;]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>3\u3001\u9650\u5236\u5206\u5272\u6b21\u6570<\/h3>\n<\/p>\n<p><p><code>split()<\/code>\u65b9\u6cd5\u8fd8\u5141\u8bb8\u4f60\u6307\u5b9a\u6700\u591a\u5206\u5272\u591a\u5c11\u6b21\u3002\u901a\u8fc7\u5411<code>split()<\/code>\u65b9\u6cd5\u4f20\u9012\u4e00\u4e2a\u6574\u6570\u53c2\u6570\uff0c\u4f60\u53ef\u4ee5\u63a7\u5236\u8fd4\u56de\u5217\u8868\u4e2d\u7684\u5143\u7d20\u6570\u91cf\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">text = &quot;Python is a versatile programming language&quot;<\/p>\n<p>word_list = text.split(&#39; &#39;, 2)<\/p>\n<p>print(word_list)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c<code>split()<\/code>\u65b9\u6cd5\u6700\u591a\u5206\u5272\u4e24\u6b21\uff0c\u6240\u4ee5\u8f93\u51fa\u5c06\u662f\uff1a<\/p>\n<\/p>\n<p><pre><code>[&#39;Python&#39;, &#39;is&#39;, &#39;a versatile programming language&#39;]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>\u4e8c\u3001\u4f7f\u7528list()\u6784\u9020\u51fd\u6570<\/h2>\n<\/p>\n<p><h3>1\u3001\u57fa\u672c\u7528\u6cd5<\/h3>\n<\/p>\n<p><p><code>list()<\/code>\u6784\u9020\u51fd\u6570\u53ef\u4ee5\u5c06\u4e00\u4e2a\u53ef\u8fed\u4ee3\u5bf9\u8c61\uff08\u5982\u5b57\u7b26\u4e32\uff09\u8f6c\u6362\u6210\u4e00\u4e2a\u5217\u8868\u3002\u6bcf\u4e2a\u5b57\u7b26\u5c06\u6210\u4e3a\u5217\u8868\u4e2d\u7684\u4e00\u4e2a\u5143\u7d20\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">text = &quot;Python&quot;<\/p>\n<p>char_list = list(text)<\/p>\n<p>print(char_list)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8f93\u51fa\u5c06\u662f\uff1a<\/p>\n<\/p>\n<p><pre><code>[&#39;P&#39;, &#39;y&#39;, &#39;t&#39;, &#39;h&#39;, &#39;o&#39;, &#39;n&#39;]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2\u3001\u5e94\u7528\u573a\u666f<\/h3>\n<\/p>\n<p><p>\u8fd9\u79cd\u65b9\u6cd5\u901a\u5e38\u7528\u4e8e\u9700\u8981\u5904\u7406\u5b57\u7b26\u4e32\u4e2d\u7684\u6bcf\u4e2a\u5b57\u7b26\u7684\u60c5\u51b5\uff0c\u4f8b\u5982\u5bc6\u7801\u5206\u6790\u3001\u5b57\u7b26\u7edf\u8ba1\u7b49\u3002<\/p>\n<\/p>\n<p><h2>\u4e09\u3001\u4f7f\u7528\u5217\u8868\u63a8\u5bfc\u5f0f<\/h2>\n<\/p>\n<p><h3>1\u3001\u57fa\u672c\u7528\u6cd5<\/h3>\n<\/p>\n<p><p>\u5217\u8868\u63a8\u5bfc\u5f0f\u662f\u4e00\u79cd\u975e\u5e38\u7075\u6d3b\u548c\u7b80\u6d01\u7684\u65b9\u5f0f\uff0c\u53ef\u4ee5\u6839\u636e\u4e00\u5b9a\u7684\u89c4\u5219\u751f\u6210\u5217\u8868\u3002\u4f8b\u5982\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u5217\u8868\u63a8\u5bfc\u5f0f\u5c06\u5b57\u7b26\u4e32\u4e2d\u7684\u6bcf\u4e2a\u5355\u8bcd\u5b58\u50a8\u5728\u4e00\u4e2a\u5217\u8868\u4e2d\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">text = &quot;Python is a versatile programming language&quot;<\/p>\n<p>word_list = [word for word in text.split()]<\/p>\n<p>print(word_list)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8f93\u51fa\u5c06\u662f\uff1a<\/p>\n<\/p>\n<p><pre><code>[&#39;Python&#39;, &#39;is&#39;, &#39;a&#39;, &#39;versatile&#39;, &#39;programming&#39;, &#39;language&#39;]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2\u3001\u9ad8\u7ea7\u7528\u6cd5<\/h3>\n<\/p>\n<p><p>\u4f60\u8fd8\u53ef\u4ee5\u7ed3\u5408\u6761\u4ef6\u8bed\u53e5\u548c\u590d\u6742\u7684\u8868\u8fbe\u5f0f\u6765\u751f\u6210\u5217\u8868\u3002\u4f8b\u5982\uff0c\u8fc7\u6ee4\u6389\u957f\u5ea6\u5c0f\u4e8e3\u7684\u5355\u8bcd\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">text = &quot;Python is a versatile programming language&quot;<\/p>\n<p>word_list = [word for word in text.split() if len(word) &gt;= 3]<\/p>\n<p>print(word_list)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8f93\u51fa\u5c06\u662f\uff1a<\/p>\n<\/p>\n<p><pre><code>[&#39;Python&#39;, &#39;versatile&#39;, &#39;programming&#39;, &#39;language&#39;]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>\u56db\u3001\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f<\/h2>\n<\/p>\n<p><h3>1\u3001\u57fa\u672c\u7528\u6cd5<\/h3>\n<\/p>\n<p><p>\u6b63\u5219\u8868\u8fbe\u5f0f\u662f\u4e00\u79cd\u5f3a\u5927\u7684\u5b57\u7b26\u4e32\u5904\u7406\u5de5\u5177\uff0c\u53ef\u4ee5\u7528\u6765\u5339\u914d\u590d\u6742\u7684\u6a21\u5f0f\u3002\u4f8b\u5982\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528<code>re<\/code>\u6a21\u5757\u7684<code>re.split()<\/code>\u65b9\u6cd5\u6839\u636e\u591a\u4e2a\u5206\u9694\u7b26\u62c6\u5206\u5b57\u7b26\u4e32\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import re<\/p>\n<p>text = &quot;Python,is;a:versatile programming,language&quot;<\/p>\n<p>word_list = re.split(r&#39;[ ,;:]&#39;, text)<\/p>\n<p>print(word_list)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8f93\u51fa\u5c06\u662f\uff1a<\/p>\n<\/p>\n<p><pre><code>[&#39;Python&#39;, &#39;is&#39;, &#39;a&#39;, &#39;versatile&#39;, &#39;programming&#39;, &#39;language&#39;]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2\u3001\u53bb\u9664\u7a7a\u5b57\u7b26\u4e32<\/h3>\n<\/p>\n<p><p>\u6709\u65f6\uff0c\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u62c6\u5206\u5b57\u7b26\u4e32\u540e\u4f1a\u4ea7\u751f\u4e00\u4e9b\u7a7a\u5b57\u7b26\u4e32\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528\u5217\u8868\u63a8\u5bfc\u5f0f\u6765\u8fc7\u6ee4\u6389\u8fd9\u4e9b\u7a7a\u5b57\u7b26\u4e32\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">word_list = [word for word in re.split(r&#39;[ ,;:]&#39;, text) if word]<\/p>\n<p>print(word_list)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8f93\u51fa\u5c06\u662f\uff1a<\/p>\n<\/p>\n<p><pre><code>[&#39;Python&#39;, &#39;is&#39;, &#39;a&#39;, &#39;versatile&#39;, &#39;programming&#39;, &#39;language&#39;]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>\u4e94\u3001\u5e94\u7528\u5b9e\u4f8b<\/h2>\n<\/p>\n<p><h3>1\u3001\u5904\u7406CSV\u6587\u4ef6<\/h3>\n<\/p>\n<p><p>\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u5904\u7406CSV\u6587\u4ef6\u662f\u4e00\u4e2a\u975e\u5e38\u5e38\u89c1\u7684\u4efb\u52a1\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528<code>split()<\/code>\u65b9\u6cd5\u5c06\u6bcf\u884c\u7684\u5b57\u7b26\u4e32\u62c6\u5206\u6210\u5217\u8868\uff0c\u7136\u540e\u8fdb\u884c\u8fdb\u4e00\u6b65\u5904\u7406\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">csv_line = &quot;apple,banana,cherry,date&quot;<\/p>\n<p>fruit_list = csv_line.split(&#39;,&#39;)<\/p>\n<p>print(fruit_list)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2\u3001\u5904\u7406\u65e5\u5fd7\u6587\u4ef6<\/h3>\n<\/p>\n<p><p>\u5728\u65e5\u5fd7\u6587\u4ef6\u5904\u7406\u4e2d\uff0c\u4f60\u53ef\u80fd\u9700\u8981\u6839\u636e\u7279\u5b9a\u5206\u9694\u7b26\u5c06\u6bcf\u884c\u62c6\u5206\u6210\u591a\u4e2a\u90e8\u5206\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">log_line = &quot;INFO:2023-10-01:User logged in&quot;<\/p>\n<p>log_parts = log_line.split(&#39;:&#39;)<\/p>\n<p>print(log_parts)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>3\u3001\u5904\u7406\u81ea\u7136\u8bed\u8a00\u6587\u672c<\/h3>\n<\/p>\n<p><p>\u5728\u81ea\u7136\u8bed\u8a00\u5904\u7406\uff08NLP\uff09\u9886\u57df\uff0c\u5206\u8bcd\u662f\u4e00\u4e2a\u975e\u5e38\u57fa\u672c\u7684\u4efb\u52a1\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528<code>split()<\/code>\u65b9\u6cd5\u5c06\u53e5\u5b50\u5206\u5272\u6210\u5355\u8bcd\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">sentence = &quot;Natural language processing is a fascinating field&quot;<\/p>\n<p>words = sentence.split()<\/p>\n<p>print(words)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<hr>\n<p><p>\u901a\u8fc7\u4e0a\u8ff0\u65b9\u6cd5\uff0c\u4f60\u53ef\u4ee5\u6839\u636e\u4e0d\u540c\u7684\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u65b9\u5f0f\u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u6210\u5217\u8868\u3002\u8fd9\u4e9b\u65b9\u6cd5\u4e0d\u4ec5\u7b80\u5355\u6613\u7528\uff0c\u800c\u4e14\u975e\u5e38\u7075\u6d3b\uff0c\u53ef\u4ee5\u6ee1\u8db3\u5404\u79cd\u5e94\u7528\u573a\u666f\u7684\u9700\u6c42\u3002\u65e0\u8bba\u4f60\u662f\u5904\u7406\u6587\u672c\u6570\u636e\u3001\u65e5\u5fd7\u6587\u4ef6\u8fd8\u662fCSV\u6587\u4ef6\uff0c\u638c\u63e1\u8fd9\u4e9b\u6280\u5de7\u90fd\u5c06\u6781\u5927\u5730\u63d0\u9ad8\u4f60\u7684\u5de5\u4f5c\u6548\u7387\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u5c06\u5b57\u7b26\u4e32\u6309\u7279\u5b9a\u5206\u9694\u7b26\u8f6c\u6362\u4e3a\u5217\u8868\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u5b57\u7b26\u4e32\u7684<code>split()<\/code>\u65b9\u6cd5\u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u5217\u8868\u3002\u8be5\u65b9\u6cd5\u63a5\u53d7\u4e00\u4e2a\u53ef\u9009\u53c2\u6570\uff0c\u6307\u5b9a\u5206\u9694\u7b26\u3002\u4f8b\u5982\uff0c\u5982\u679c\u6709\u4e00\u4e2a\u7528\u9017\u53f7\u5206\u9694\u7684\u5b57\u7b26\u4e32\uff0c\u53ef\u4ee5\u8fd9\u6837\u8f6c\u6362\uff1a  <\/p>\n<pre><code class=\"language-python\">string = &quot;\u82f9\u679c,\u9999\u8549,\u6a58\u5b50&quot;\n\u5217\u8868 = string.split(&quot;,&quot;)\nprint(\u5217\u8868)  # \u8f93\u51fa: [&#39;\u82f9\u679c&#39;, &#39;\u9999\u8549&#39;, &#39;\u6a58\u5b50&#39;]\n<\/code><\/pre>\n<p>\u5982\u679c\u4e0d\u4f20\u5165\u5206\u9694\u7b26\uff0c<code>split()<\/code>\u4f1a\u9ed8\u8ba4\u6309\u7a7a\u683c\u8fdb\u884c\u5206\u5272\u3002<\/p>\n<p><strong>\u5982\u4f55\u5c06\u5b57\u7b26\u4e32\u4e2d\u7684\u6bcf\u4e2a\u5b57\u7b26\u8f6c\u6362\u4e3a\u5217\u8868\u4e2d\u7684\u5143\u7d20\uff1f<\/strong><br \/>\u4f7f\u7528<code>list()<\/code>\u51fd\u6570\u53ef\u4ee5\u5c06\u5b57\u7b26\u4e32\u4e2d\u7684\u6bcf\u4e2a\u5b57\u7b26\u8f6c\u6362\u4e3a\u5217\u8868\u4e2d\u7684\u5355\u72ec\u5143\u7d20\u3002\u793a\u4f8b\u5982\u4e0b\uff1a  <\/p>\n<pre><code class=\"language-python\">string = &quot;hello&quot;\n\u5217\u8868 = list(string)\nprint(\u5217\u8868)  # \u8f93\u51fa: [&#39;h&#39;, &#39;e&#39;, &#39;l&#39;, &#39;l&#39;, &#39;o&#39;]\n<\/code><\/pre>\n<p>\u8fd9\u79cd\u65b9\u6cd5\u9002\u7528\u4e8e\u9700\u8981\u9010\u5b57\u7b26\u5904\u7406\u7684\u573a\u666f\u3002<\/p>\n<p><strong>\u5982\u4f55\u5904\u7406\u5305\u542b\u591a\u4e2a\u5206\u9694\u7b26\u7684\u5b57\u7b26\u4e32\u5e76\u8f6c\u6362\u4e3a\u5217\u8868\uff1f<\/strong><br \/>\u5728\u5904\u7406\u5305\u542b\u591a\u4e2a\u5206\u9694\u7b26\u7684\u5b57\u7b26\u4e32\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528<code>re<\/code>\u6a21\u5757\u4e2d\u7684<code>split()<\/code>\u51fd\u6570\u3002\u8be5\u51fd\u6570\u5141\u8bb8\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u6307\u5b9a\u591a\u4e2a\u5206\u9694\u7b26\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a  <\/p>\n<pre><code class=\"language-python\">import re\n\nstring = &quot;\u82f9\u679c;\u9999\u8549,\u6a58\u5b50.\u8461\u8404&quot;\n\u5217\u8868 = re.split(r&#39;[;,.]&#39;, string)\nprint(\u5217\u8868)  # \u8f93\u51fa: [&#39;\u82f9\u679c&#39;, &#39;\u9999\u8549&#39;, &#39;\u6a58\u5b50&#39;, &#39;\u8461\u8404&#39;]\n<\/code><\/pre>\n<p>\u8fd9\u79cd\u65b9\u6cd5\u7075\u6d3b\u6027\u9ad8\uff0c\u9002\u7528\u4e8e\u590d\u6742\u7684\u5b57\u7b26\u4e32\u62c6\u5206\u9700\u6c42\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u6210\u5217\u8868\u5728Python\u4e2d\u53ef\u4ee5\u4f7f\u7528\u591a\u79cd\u65b9\u6cd5\uff0c\u4e3b\u8981\u65b9\u6cd5\u5305\u62ec\uff1a\u4f7f\u7528split()\u65b9\u6cd5\u3001\u4f7f\u7528list()\u6784\u9020 [&hellip;]","protected":false},"author":3,"featured_media":1136467,"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\/1136464"}],"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=1136464"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1136464\/revisions"}],"predecessor-version":[{"id":1136470,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1136464\/revisions\/1136470"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1136467"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1136464"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1136464"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1136464"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}