{"id":1180179,"date":"2025-01-15T18:33:39","date_gmt":"2025-01-15T10:33:39","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1180179.html"},"modified":"2025-01-15T18:33:41","modified_gmt":"2025-01-15T10:33:41","slug":"python%e5%a6%82%e4%bd%95%e5%b0%86-n%e5%8e%bb%e6%8e%89","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1180179.html","title":{"rendered":"python\u5982\u4f55\u5c06 n\u53bb\u6389"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25114349\/418a72ff-bc24-4a8e-b849-c92ff30f800e.webp\" alt=\"python\u5982\u4f55\u5c06 n\u53bb\u6389\" \/><\/p>\n<p><p> <strong>\u4f7f\u7528\u5b57\u7b26\u4e32\u65b9\u6cd5\u3001\u6b63\u5219\u8868\u8fbe\u5f0f\u3001\u904d\u5386\u66ff\u6362\u7b49\u65b9\u6cd5\u53ef\u4ee5\u5c06\u5b57\u7b26\u4e32\u4e2d\u7684\u6362\u884c\u7b26\uff08<code>\\n<\/code>\uff09\u53bb\u6389\u3002<\/strong> \u5176\u4e2d\uff0c<strong>\u5b57\u7b26\u4e32\u65b9\u6cd5<\/strong>\u662f\u4e00\u79cd\u5e38\u89c1\u4e14\u7b80\u5355\u7684\u65b9\u6cd5\uff0c\u901a\u8fc7\u4f7f\u7528<code>replace()<\/code>\u65b9\u6cd5\u53ef\u4ee5\u8f7b\u677e\u5b9e\u73b0\u3002\u5177\u4f53\u6765\u8bf4\uff0c\u53ef\u4ee5\u5c06\u5b57\u7b26\u4e32\u4e2d\u7684\u6240\u6709<code>\\n<\/code>\u66ff\u6362\u4e3a\u7a7a\u5b57\u7b26\u4e32\uff0c\u4ece\u800c\u8fbe\u5230\u53bb\u6389\u6362\u884c\u7b26\u7684\u6548\u679c\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u5b57\u7b26\u4e32\u65b9\u6cd5<\/h3>\n<\/p>\n<p><p>\u4f7f\u7528\u5b57\u7b26\u4e32\u65b9\u6cd5\u53bb\u6389\u6362\u884c\u7b26\u662f\u6700\u76f4\u63a5\u7684\u65b9\u6cd5\u4e4b\u4e00\u3002Python \u7684 <code>replace()<\/code> \u65b9\u6cd5\u53ef\u4ee5\u7528\u6765\u66ff\u6362\u5b57\u7b26\u4e32\u4e2d\u7684\u5b50\u5b57\u7b26\u4e32\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06\u6240\u6709\u7684\u6362\u884c\u7b26\u66ff\u6362\u4e3a\u7a7a\u5b57\u7b26\u4e32\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">text = &quot;Hello\\nWorld\\nPython&quot;<\/p>\n<p>cleaned_text = text.replace(&quot;\\n&quot;, &quot;&quot;)<\/p>\n<p>print(cleaned_text)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>text.replace(&quot;\\n&quot;, &quot;&quot;)<\/code> \u5c06\u5b57\u7b26\u4e32 <code>text<\/code> \u4e2d\u7684\u6240\u6709\u6362\u884c\u7b26\u66ff\u6362\u4e3a\u7a7a\u5b57\u7b26\u4e32\uff0c\u7ed3\u679c\u662f <code>HelloWorldPython<\/code>\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u6b63\u5219\u8868\u8fbe\u5f0f<\/h3>\n<\/p>\n<p><p>\u6b63\u5219\u8868\u8fbe\u5f0f\u662f\u5904\u7406\u5b57\u7b26\u4e32\u7684\u4e00\u79cd\u5f3a\u5927\u5de5\u5177\u3002Python \u63d0\u4f9b\u4e86 <code>re<\/code> \u6a21\u5757\uff0c\u53ef\u4ee5\u7528\u6765\u8fdb\u884c\u590d\u6742\u7684\u5b57\u7b26\u4e32\u64cd\u4f5c\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u6765\u53bb\u6389\u5b57\u7b26\u4e32\u4e2d\u7684\u6240\u6709\u6362\u884c\u7b26\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import re<\/p>\n<p>text = &quot;Hello\\nWorld\\nPython&quot;<\/p>\n<p>cleaned_text = re.sub(r&#39;\\n&#39;, &#39;&#39;, text)<\/p>\n<p>print(cleaned_text)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>re.sub(r&#39;\\n&#39;, &#39;&#39;, text)<\/code> \u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u5c06\u6240\u6709\u7684\u6362\u884c\u7b26\u66ff\u6362\u4e3a\u7a7a\u5b57\u7b26\u4e32\u3002\u6b63\u5219\u8868\u8fbe\u5f0f\u4e2d\u7684 <code>\\n<\/code> \u5339\u914d\u6362\u884c\u7b26\uff0c<code>re.sub<\/code> \u65b9\u6cd5\u5c06\u5176\u66ff\u6362\u4e3a\u7a7a\u5b57\u7b26\u4e32\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u904d\u5386\u66ff\u6362<\/h3>\n<\/p>\n<p><p>\u53e6\u4e00\u79cd\u65b9\u6cd5\u662f\u904d\u5386\u5b57\u7b26\u4e32\u4e2d\u7684\u6bcf\u4e2a\u5b57\u7b26\uff0c\u5e76\u5c06\u4e0d\u662f\u6362\u884c\u7b26\u7684\u5b57\u7b26\u6dfb\u52a0\u5230\u65b0\u7684\u5b57\u7b26\u4e32\u4e2d\u3002\u867d\u7136\u8fd9\u79cd\u65b9\u6cd5\u4e0d\u5982\u524d\u4e24\u79cd\u65b9\u6cd5\u7b80\u6d01\uff0c\u4f46\u5b83\u5c55\u793a\u4e86\u5b57\u7b26\u4e32\u5904\u7406\u7684\u57fa\u672c\u539f\u7406\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">text = &quot;Hello\\nWorld\\nPython&quot;<\/p>\n<p>cleaned_text = &#39;&#39;.join([char for char in text if char != &#39;\\n&#39;])<\/p>\n<p>print(cleaned_text)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u5217\u8868\u63a8\u5bfc\u5f0f <code>[char for char in text if char != &#39;\\n&#39;]<\/code> \u904d\u5386\u5b57\u7b26\u4e32 <code>text<\/code> \u4e2d\u7684\u6bcf\u4e2a\u5b57\u7b26\uff0c\u53ea\u6709\u4e0d\u662f\u6362\u884c\u7b26\u7684\u5b57\u7b26\u624d\u4f1a\u88ab\u6dfb\u52a0\u5230\u65b0\u7684\u5217\u8868\u4e2d\u3002\u7136\u540e\uff0c\u4f7f\u7528 <code>join()<\/code> \u65b9\u6cd5\u5c06\u5217\u8868\u4e2d\u7684\u5b57\u7b26\u8fde\u63a5\u6210\u65b0\u7684\u5b57\u7b26\u4e32\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u5b57\u7b26\u4e32\u5206\u5272\u4e0e\u8fde\u63a5<\/h3>\n<\/p>\n<p><p>\u6211\u4eec\u8fd8\u53ef\u4ee5\u5148\u5c06\u5b57\u7b26\u4e32\u6309\u6362\u884c\u7b26\u5206\u5272\u6210\u591a\u4e2a\u5b50\u5b57\u7b26\u4e32\uff0c\u7136\u540e\u518d\u5c06\u8fd9\u4e9b\u5b50\u5b57\u7b26\u4e32\u8fde\u63a5\u8d77\u6765\u3002\u8fd9\u79cd\u65b9\u6cd5\u540c\u6837\u53ef\u4ee5\u8fbe\u5230\u53bb\u6389\u6362\u884c\u7b26\u7684\u6548\u679c\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">text = &quot;Hello\\nWorld\\nPython&quot;<\/p>\n<p>cleaned_text = &#39;&#39;.join(text.split(&#39;\\n&#39;))<\/p>\n<p>print(cleaned_text)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>text.split(&#39;\\n&#39;)<\/code> \u5c06\u5b57\u7b26\u4e32 <code>text<\/code> \u6309\u6362\u884c\u7b26\u5206\u5272\u6210\u591a\u4e2a\u5b50\u5b57\u7b26\u4e32\uff0c\u5f97\u5230\u4e00\u4e2a\u5217\u8868\u3002\u7136\u540e\uff0c\u4f7f\u7528 <code>join()<\/code> \u65b9\u6cd5\u5c06\u5217\u8868\u4e2d\u7684\u5b50\u5b57\u7b26\u4e32\u8fde\u63a5\u6210\u65b0\u7684\u5b57\u7b26\u4e32\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001\u5b57\u7b26\u4e32\u66ff\u6362\uff08translate\u65b9\u6cd5\uff09<\/h3>\n<\/p>\n<p><p>Python \u7684 <code>translate()<\/code> \u65b9\u6cd5\u7ed3\u5408 <code>str.maketrans()<\/code> \u65b9\u6cd5\u4e5f\u53ef\u4ee5\u7528\u6765\u53bb\u6389\u6362\u884c\u7b26\u3002<code>str.maketrans()<\/code> \u521b\u5efa\u4e00\u4e2a\u5b57\u7b26\u6620\u5c04\u8868\uff0c<code>translate()<\/code> \u65b9\u6cd5\u4f7f\u7528\u8fd9\u4e2a\u6620\u5c04\u8868\u66ff\u6362\u5b57\u7b26\u4e32\u4e2d\u7684\u5b57\u7b26\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">text = &quot;Hello\\nWorld\\nPython&quot;<\/p>\n<p>cleaned_text = text.translate(str.maketrans(&#39;&#39;, &#39;&#39;, &#39;\\n&#39;))<\/p>\n<p>print(cleaned_text)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>str.maketrans(&#39;&#39;, &#39;&#39;, &#39;\\n&#39;)<\/code> \u521b\u5efa\u4e86\u4e00\u4e2a\u6620\u5c04\u8868\uff0c\u8868\u793a\u5c06\u6362\u884c\u7b26\u6620\u5c04\u4e3a\u7a7a\u5b57\u7b26\u3002<code>text.translate()<\/code> \u4f7f\u7528\u8fd9\u4e2a\u6620\u5c04\u8868\u5c06\u5b57\u7b26\u4e32\u4e2d\u7684\u6362\u884c\u7b26\u53bb\u6389\u3002<\/p>\n<\/p>\n<p><h3>\u516d\u3001\u9010\u884c\u8bfb\u53d6\u4e0e\u5904\u7406<\/h3>\n<\/p>\n<p><p>\u5bf9\u4e8e\u8f83\u5927\u7684\u6587\u4ef6\u6216\u591a\u884c\u6587\u672c\uff0c\u53ef\u4ee5\u9010\u884c\u8bfb\u53d6\u5e76\u5904\u7406\u6bcf\u4e00\u884c\uff0c\u7136\u540e\u5c06\u5904\u7406\u540e\u7684\u884c\u8fde\u63a5\u8d77\u6765\u3002\u8fd9\u79cd\u65b9\u6cd5\u7279\u522b\u9002\u7528\u4e8e\u5904\u7406\u5927\u6587\u4ef6\uff0c\u907f\u514d\u4e00\u6b21\u6027\u5c06\u6574\u4e2a\u6587\u4ef6\u52a0\u8f7d\u5230\u5185\u5b58\u4e2d\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">text = &quot;&quot;&quot;Hello<\/p>\n<p>World<\/p>\n<p>Python&quot;&quot;&quot;<\/p>\n<p>lines = text.splitlines()<\/p>\n<p>cleaned_text = &#39;&#39;.join(lines)<\/p>\n<p>print(cleaned_text)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>text.splitlines()<\/code> \u65b9\u6cd5\u5c06\u5b57\u7b26\u4e32\u6309\u884c\u5206\u5272\u6210\u591a\u4e2a\u5b50\u5b57\u7b26\u4e32\uff0c\u7136\u540e\u4f7f\u7528 <code>join()<\/code> \u65b9\u6cd5\u5c06\u8fd9\u4e9b\u5b50\u5b57\u7b26\u4e32\u8fde\u63a5\u6210\u65b0\u7684\u5b57\u7b26\u4e32\u3002<\/p>\n<\/p>\n<p><h3>\u4e03\u3001\u4f7f\u7528\u5217\u8868\u63a8\u5bfc\u5f0f<\/h3>\n<\/p>\n<p><p>\u5217\u8868\u63a8\u5bfc\u5f0f\u662f\u4e00\u79cd\u7b80\u6d01\u7684\u65b9\u6cd5\u6765\u751f\u6210\u65b0\u7684\u5217\u8868\u3002\u5728\u53bb\u6389\u6362\u884c\u7b26\u7684\u8fc7\u7a0b\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u5217\u8868\u63a8\u5bfc\u5f0f\u751f\u6210\u4e00\u4e2a\u4e0d\u5305\u542b\u6362\u884c\u7b26\u7684\u5b57\u7b26\u5217\u8868\uff0c\u7136\u540e\u5c06\u5176\u8fde\u63a5\u6210\u5b57\u7b26\u4e32\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">text = &quot;Hello\\nWorld\\nPython&quot;<\/p>\n<p>cleaned_text = &#39;&#39;.join([char for char in text if char != &#39;\\n&#39;])<\/p>\n<p>print(cleaned_text)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u5217\u8868\u63a8\u5bfc\u5f0f <code>[char for char in text if char != &#39;\\n&#39;]<\/code> \u904d\u5386\u5b57\u7b26\u4e32 <code>text<\/code> \u4e2d\u7684\u6bcf\u4e2a\u5b57\u7b26\uff0c\u53ea\u6709\u4e0d\u662f\u6362\u884c\u7b26\u7684\u5b57\u7b26\u624d\u4f1a\u88ab\u6dfb\u52a0\u5230\u65b0\u7684\u5217\u8868\u4e2d\u3002\u7136\u540e\uff0c\u4f7f\u7528 <code>join()<\/code> \u65b9\u6cd5\u5c06\u5217\u8868\u4e2d\u7684\u5b57\u7b26\u8fde\u63a5\u6210\u65b0\u7684\u5b57\u7b26\u4e32\u3002<\/p>\n<\/p>\n<p><h3>\u516b\u3001\u5904\u7406\u5927\u6587\u4ef6<\/h3>\n<\/p>\n<p><p>\u5bf9\u4e8e\u5904\u7406\u5927\u6587\u4ef6\uff0c\u53ef\u4ee5\u9010\u884c\u8bfb\u53d6\u6587\u4ef6\u5185\u5bb9\u5e76\u53bb\u6389\u6bcf\u884c\u672b\u5c3e\u7684\u6362\u884c\u7b26\uff0c\u7136\u540e\u5c06\u5904\u7406\u540e\u7684\u5185\u5bb9\u5199\u5165\u65b0\u7684\u6587\u4ef6\u3002\u8fd9\u79cd\u65b9\u6cd5\u907f\u514d\u4e86\u4e00\u6b21\u6027\u5c06\u6574\u4e2a\u6587\u4ef6\u52a0\u8f7d\u5230\u5185\u5b58\u4e2d\uff0c\u9002\u7528\u4e8e\u5904\u7406\u5927\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">input_file = &#39;input.txt&#39;<\/p>\n<p>output_file = &#39;output.txt&#39;<\/p>\n<p>with open(input_file, &#39;r&#39;) as infile, open(output_file, &#39;w&#39;) as outfile:<\/p>\n<p>    for line in infile:<\/p>\n<p>        cleaned_line = line.strip(&#39;\\n&#39;)<\/p>\n<p>        outfile.write(cleaned_line)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u4f7f\u7528 <code>with open()<\/code> \u8bed\u53e5\u6253\u5f00\u8f93\u5165\u6587\u4ef6\u548c\u8f93\u51fa\u6587\u4ef6\u3002\u9010\u884c\u8bfb\u53d6\u8f93\u5165\u6587\u4ef6\u7684\u5185\u5bb9\uff0c\u5e76\u4f7f\u7528 <code>strip(&#39;\\n&#39;)<\/code> \u65b9\u6cd5\u53bb\u6389\u6bcf\u884c\u672b\u5c3e\u7684\u6362\u884c\u7b26\uff0c\u7136\u540e\u5c06\u5904\u7406\u540e\u7684\u5185\u5bb9\u5199\u5165\u8f93\u51fa\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><h3>\u4e5d\u3001\u4f7f\u7528\u81ea\u5b9a\u4e49\u51fd\u6570<\/h3>\n<\/p>\n<p><p>\u6211\u4eec\u8fd8\u53ef\u4ee5\u7f16\u5199\u4e00\u4e2a\u81ea\u5b9a\u4e49\u51fd\u6570\u6765\u53bb\u6389\u5b57\u7b26\u4e32\u4e2d\u7684\u6362\u884c\u7b26\u3002\u8fd9\u79cd\u65b9\u6cd5\u589e\u52a0\u4e86\u4ee3\u7801\u7684\u53ef\u91cd\u7528\u6027\u548c\u53ef\u8bfb\u6027\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def remove_newlines(text):<\/p>\n<p>    return text.replace(&quot;\\n&quot;, &quot;&quot;)<\/p>\n<p>text = &quot;Hello\\nWorld\\nPython&quot;<\/p>\n<p>cleaned_text = remove_newlines(text)<\/p>\n<p>print(cleaned_text)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u5b9a\u4e49\u4e86\u4e00\u4e2a\u540d\u4e3a <code>remove_newlines<\/code> \u7684\u51fd\u6570\uff0c\u8be5\u51fd\u6570\u4f7f\u7528 <code>replace()<\/code> \u65b9\u6cd5\u5c06\u5b57\u7b26\u4e32\u4e2d\u7684\u6240\u6709\u6362\u884c\u7b26\u66ff\u6362\u4e3a\u7a7a\u5b57\u7b26\u4e32\u3002\u7136\u540e\u8c03\u7528\u8fd9\u4e2a\u51fd\u6570\u6765\u53bb\u6389\u5b57\u7b26\u4e32\u4e2d\u7684\u6362\u884c\u7b26\u3002<\/p>\n<\/p>\n<p><h3>\u5341\u3001\u4f7f\u7528\u9012\u5f52\u65b9\u6cd5<\/h3>\n<\/p>\n<p><p>\u5bf9\u4e8e\u67d0\u4e9b\u7279\u5b9a\u60c5\u51b5\uff0c\u53ef\u4ee5\u4f7f\u7528\u9012\u5f52\u65b9\u6cd5\u6765\u53bb\u6389\u5b57\u7b26\u4e32\u4e2d\u7684\u6362\u884c\u7b26\u3002\u9012\u5f52\u65b9\u6cd5\u662f\u4e00\u79cd\u51fd\u6570\u8c03\u7528\u81ea\u8eab\u7684\u7f16\u7a0b\u6280\u672f\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def remove_newlines_recursive(text):<\/p>\n<p>    if &#39;\\n&#39; not in text:<\/p>\n<p>        return text<\/p>\n<p>    return remove_newlines_recursive(text.replace(&#39;\\n&#39;, &#39;&#39;, 1))<\/p>\n<p>text = &quot;Hello\\nWorld\\nPython&quot;<\/p>\n<p>cleaned_text = remove_newlines_recursive(text)<\/p>\n<p>print(cleaned_text)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u5b9a\u4e49\u4e86\u4e00\u4e2a\u540d\u4e3a <code>remove_newlines_recursive<\/code> \u7684\u9012\u5f52\u51fd\u6570\u3002\u8be5\u51fd\u6570\u9996\u5148\u68c0\u67e5\u5b57\u7b26\u4e32\u4e2d\u662f\u5426\u5305\u542b\u6362\u884c\u7b26\uff0c\u5982\u679c\u4e0d\u5305\u542b\u5219\u8fd4\u56de\u5b57\u7b26\u4e32\uff1b\u5426\u5219\uff0c\u66ff\u6362\u7b2c\u4e00\u4e2a\u6362\u884c\u7b26\u5e76\u9012\u5f52\u8c03\u7528\u81ea\u8eab\u3002<\/p>\n<\/p>\n<p><h3>\u5341\u4e00\u3001\u4f7f\u7528\u8fed\u4ee3\u5668<\/h3>\n<\/p>\n<p><p>\u8fed\u4ee3\u5668\u662f\u4e00\u79cd\u53ef\u4ee5\u9010\u4e2a\u8bbf\u95ee\u5143\u7d20\u7684\u5bf9\u8c61\u3002\u901a\u8fc7\u4f7f\u7528\u8fed\u4ee3\u5668\uff0c\u6211\u4eec\u53ef\u4ee5\u9010\u4e2a\u5904\u7406\u5b57\u7b26\u4e32\u4e2d\u7684\u6bcf\u4e2a\u5b57\u7b26\uff0c\u53bb\u6389\u6362\u884c\u7b26\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">text = &quot;Hello\\nWorld\\nPython&quot;<\/p>\n<p>cleaned_text = &#39;&#39;.join(char for char in iter(text) if char != &#39;\\n&#39;)<\/p>\n<p>print(cleaned_text)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u4f7f\u7528 <code>iter(text)<\/code> \u521b\u5efa\u4e00\u4e2a\u5b57\u7b26\u4e32\u7684\u8fed\u4ee3\u5668\uff0c\u7136\u540e\u4f7f\u7528\u751f\u6210\u5668\u8868\u8fbe\u5f0f\u904d\u5386\u8fed\u4ee3\u5668\u4e2d\u7684\u6bcf\u4e2a\u5b57\u7b26\uff0c\u53bb\u6389\u6362\u884c\u7b26\u5e76\u5c06\u5176\u8fde\u63a5\u6210\u65b0\u7684\u5b57\u7b26\u4e32\u3002<\/p>\n<\/p>\n<p><h3>\u5341\u4e8c\u3001\u7ed3\u5408\u591a\u79cd\u65b9\u6cd5<\/h3>\n<\/p>\n<p><p>\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u7ed3\u5408\u591a\u79cd\u65b9\u6cd5\u6765\u5904\u7406\u5b57\u7b26\u4e32\u4e2d\u7684\u6362\u884c\u7b26\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u5148\u4f7f\u7528 <code>splitlines()<\/code> \u65b9\u6cd5\u5c06\u5b57\u7b26\u4e32\u6309\u884c\u5206\u5272\uff0c\u7136\u540e\u4f7f\u7528 <code>join()<\/code> \u65b9\u6cd5\u5c06\u5176\u8fde\u63a5\u6210\u65b0\u7684\u5b57\u7b26\u4e32\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">text = &quot;&quot;&quot;Hello<\/p>\n<p>World<\/p>\n<p>Python&quot;&quot;&quot;<\/p>\n<p>cleaned_text = &#39;&#39;.join(text.splitlines())<\/p>\n<p>print(cleaned_text)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>text.splitlines()<\/code> \u65b9\u6cd5\u5c06\u5b57\u7b26\u4e32\u6309\u884c\u5206\u5272\u6210\u591a\u4e2a\u5b50\u5b57\u7b26\u4e32\uff0c\u7136\u540e\u4f7f\u7528 <code>join()<\/code> \u65b9\u6cd5\u5c06\u8fd9\u4e9b\u5b50\u5b57\u7b26\u4e32\u8fde\u63a5\u6210\u65b0\u7684\u5b57\u7b26\u4e32\u3002<\/p>\n<\/p>\n<p><h3>\u5341\u4e09\u3001\u5904\u7406\u591a\u79cd\u6362\u884c\u7b26<\/h3>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u5b57\u7b26\u4e32\u4e2d\u53ef\u80fd\u5305\u542b\u591a\u79cd\u6362\u884c\u7b26\uff0c\u4f8b\u5982 <code>\\n<\/code> \u548c <code>\\r\\n<\/code>\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u6765\u5904\u7406\u8fd9\u4e9b\u60c5\u51b5\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import re<\/p>\n<p>text = &quot;Hello\\r\\nWorld\\nPython&quot;<\/p>\n<p>cleaned_text = re.sub(r&#39;\\r?\\n&#39;, &#39;&#39;, text)<\/p>\n<p>print(cleaned_text)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>re.sub(r&#39;\\r?\\n&#39;, &#39;&#39;, text)<\/code> \u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u5c06\u6240\u6709\u7684\u6362\u884c\u7b26\uff08\u5305\u62ec <code>\\n<\/code> \u548c <code>\\r\\n<\/code>\uff09\u66ff\u6362\u4e3a\u7a7a\u5b57\u7b26\u4e32\u3002\u6b63\u5219\u8868\u8fbe\u5f0f\u4e2d\u7684 <code>\\r?\\n<\/code> \u5339\u914d <code>\\n<\/code> \u6216\u8005 <code>\\r\\n<\/code>\u3002<\/p>\n<\/p>\n<p><h3>\u5341\u56db\u3001\u5904\u7406\u7279\u6b8a\u5b57\u7b26<\/h3>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u5b57\u7b26\u4e32\u4e2d\u53ef\u80fd\u5305\u542b\u5176\u4ed6\u7279\u6b8a\u5b57\u7b26\uff0c\u4f8b\u5982\u5236\u8868\u7b26\uff08<code>\\t<\/code>\uff09\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 <code>replace()<\/code> \u65b9\u6cd5\u6765\u53bb\u6389\u8fd9\u4e9b\u7279\u6b8a\u5b57\u7b26\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">text = &quot;Hello\\tWorld\\nPython&quot;<\/p>\n<p>cleaned_text = text.replace(&quot;\\n&quot;, &quot;&quot;).replace(&quot;\\t&quot;, &quot;&quot;)<\/p>\n<p>print(cleaned_text)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>text.replace(&quot;\\n&quot;, &quot;&quot;).replace(&quot;\\t&quot;, &quot;&quot;)<\/code> \u5c06\u5b57\u7b26\u4e32\u4e2d\u7684\u6362\u884c\u7b26\u548c\u5236\u8868\u7b26\u66ff\u6362\u4e3a\u7a7a\u5b57\u7b26\u4e32\u3002<\/p>\n<\/p>\n<p><h3>\u5341\u4e94\u3001\u5904\u7406\u591a\u884c\u5b57\u7b26\u4e32<\/h3>\n<\/p>\n<p><p>\u5bf9\u4e8e\u591a\u884c\u5b57\u7b26\u4e32\uff0c\u53ef\u4ee5\u4f7f\u7528 <code>splitlines()<\/code> \u65b9\u6cd5\u5c06\u5b57\u7b26\u4e32\u6309\u884c\u5206\u5272\uff0c\u7136\u540e\u4f7f\u7528\u5217\u8868\u63a8\u5bfc\u5f0f\u53bb\u6389\u6bcf\u884c\u672b\u5c3e\u7684\u6362\u884c\u7b26\uff0c\u6700\u540e\u4f7f\u7528 <code>join()<\/code> \u65b9\u6cd5\u5c06\u5176\u8fde\u63a5\u6210\u65b0\u7684\u5b57\u7b26\u4e32\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">text = &quot;&quot;&quot;Hello<\/p>\n<p>World<\/p>\n<p>Python&quot;&quot;&quot;<\/p>\n<p>lines = text.splitlines()<\/p>\n<p>cleaned_text = &#39;&#39;.join([line for line in lines])<\/p>\n<p>print(cleaned_text)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>text.splitlines()<\/code> \u65b9\u6cd5\u5c06\u5b57\u7b26\u4e32\u6309\u884c\u5206\u5272\u6210\u591a\u4e2a\u5b50\u5b57\u7b26\u4e32\uff0c\u7136\u540e\u4f7f\u7528\u5217\u8868\u63a8\u5bfc\u5f0f\u53bb\u6389\u6bcf\u884c\u672b\u5c3e\u7684\u6362\u884c\u7b26\uff0c\u6700\u540e\u4f7f\u7528 <code>join()<\/code> \u65b9\u6cd5\u5c06\u5176\u8fde\u63a5\u6210\u65b0\u7684\u5b57\u7b26\u4e32\u3002<\/p>\n<\/p>\n<p><h3>\u5341\u516d\u3001\u5904\u7406\u6df7\u5408\u5185\u5bb9<\/h3>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u5b57\u7b26\u4e32\u4e2d\u53ef\u80fd\u5305\u542b\u6df7\u5408\u5185\u5bb9\uff0c\u4f8b\u5982\u6587\u672c\u548c\u6362\u884c\u7b26\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u5b57\u7b26\u4e32\u65b9\u6cd5\u6765\u53bb\u6389\u6362\u884c\u7b26\uff0c\u5e76\u4fdd\u7559\u5176\u4ed6\u5185\u5bb9\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">text = &quot;Hello\\nWorld\\nPython\\n123&quot;<\/p>\n<p>cleaned_text = text.replace(&quot;\\n&quot;, &quot;&quot;)<\/p>\n<p>print(cleaned_text)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>text.replace(&quot;\\n&quot;, &quot;&quot;)<\/code> \u5c06\u5b57\u7b26\u4e32\u4e2d\u7684\u6362\u884c\u7b26\u66ff\u6362\u4e3a\u7a7a\u5b57\u7b26\u4e32\uff0c\u5e76\u4fdd\u7559\u5176\u4ed6\u5185\u5bb9\u3002<\/p>\n<\/p>\n<p><h3>\u5341\u4e03\u3001\u5904\u7406\u975e\u6253\u5370\u5b57\u7b26<\/h3>\n<\/p>\n<p><p>\u9664\u4e86\u6362\u884c\u7b26\uff0c\u5b57\u7b26\u4e32\u4e2d\u53ef\u80fd\u8fd8\u5305\u542b\u5176\u4ed6\u975e\u6253\u5370\u5b57\u7b26\uff0c\u4f8b\u5982\u56de\u8f66\u7b26\uff08<code>\\r<\/code>\uff09\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 <code>translate()<\/code> \u65b9\u6cd5\u7ed3\u5408 <code>str.maketrans()<\/code> \u65b9\u6cd5\u6765\u53bb\u6389\u8fd9\u4e9b\u975e\u6253\u5370\u5b57\u7b26\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">text = &quot;Hello\\r\\nWorld\\nPython&quot;<\/p>\n<p>cleaned_text = text.translate(str.maketrans(&#39;&#39;, &#39;&#39;, &#39;\\n\\r&#39;))<\/p>\n<p>print(cleaned_text)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>str.maketrans(&#39;&#39;, &#39;&#39;, &#39;\\n\\r&#39;)<\/code> \u521b\u5efa\u4e86\u4e00\u4e2a\u6620\u5c04\u8868\uff0c\u8868\u793a\u5c06\u6362\u884c\u7b26\u548c\u56de\u8f66\u7b26\u6620\u5c04\u4e3a\u7a7a\u5b57\u7b26\u3002<code>text.translate()<\/code> \u4f7f\u7528\u8fd9\u4e2a\u6620\u5c04\u8868\u5c06\u5b57\u7b26\u4e32\u4e2d\u7684\u6362\u884c\u7b26\u548c\u56de\u8f66\u7b26\u53bb\u6389\u3002<\/p>\n<\/p>\n<p><h3>\u5341\u516b\u3001\u5904\u7406\u591a\u79cd\u7f16\u7801<\/h3>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u5b57\u7b26\u4e32\u53ef\u80fd\u4f7f\u7528\u4e0d\u540c\u7684\u7f16\u7801\u65b9\u5f0f\uff0c\u4f8b\u5982 UTF-8 \u548c ASCII\u3002\u6211\u4eec\u53ef\u4ee5\u5148\u5c06\u5b57\u7b26\u4e32\u89e3\u7801\u4e3a Unicode\uff0c\u7136\u540e\u4f7f\u7528\u5b57\u7b26\u4e32\u65b9\u6cd5\u53bb\u6389\u6362\u884c\u7b26\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">text = &quot;Hello\\nWorld\\nPython&quot;<\/p>\n<p>cleaned_text = text.replace(&quot;\\n&quot;, &quot;&quot;).encode(&#39;utf-8&#39;).decode(&#39;utf-8&#39;)<\/p>\n<p>print(cleaned_text)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>text.replace(&quot;\\n&quot;, &quot;&quot;).encode(&#39;utf-8&#39;).decode(&#39;utf-8&#39;)<\/code> \u5148\u5c06\u5b57\u7b26\u4e32\u4e2d\u7684\u6362\u884c\u7b26\u66ff\u6362\u4e3a\u7a7a\u5b57\u7b26\u4e32\uff0c\u7136\u540e\u5c06\u5b57\u7b26\u4e32\u7f16\u7801\u4e3a UTF-8\uff0c\u518d\u89e3\u7801\u4e3a Unicode\u3002<\/p>\n<\/p>\n<p><h3>\u5341\u4e5d\u3001\u5904\u7406\u591a\u79cd\u683c\u5f0f<\/h3>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u5b57\u7b26\u4e32\u53ef\u80fd\u5305\u542b\u591a\u79cd\u683c\u5f0f\uff0c\u4f8b\u5982 HTML \u548c XML\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u6765\u53bb\u6389\u8fd9\u4e9b\u683c\u5f0f\u4e2d\u7684\u6362\u884c\u7b26\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import re<\/p>\n<p>text = &quot;&lt;html&gt;\\n&lt;body&gt;\\nHello\\nWorld\\n&lt;\/body&gt;\\n&lt;\/html&gt;&quot;<\/p>\n<p>cleaned_text = re.sub(r&#39;\\n&#39;, &#39;&#39;, text)<\/p>\n<p>print(cleaned_text)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>re.sub(r&#39;\\n&#39;, &#39;&#39;, text)<\/code> \u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u5c06 HTML \u683c\u5f0f\u4e2d\u7684\u6240\u6709\u6362\u884c\u7b26\u66ff\u6362\u4e3a\u7a7a\u5b57\u7b26\u4e32\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u5341\u3001\u5904\u7406\u591a\u8bed\u8a00\u6587\u672c<\/h3>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u5b57\u7b26\u4e32\u53ef\u80fd\u5305\u542b\u591a\u79cd\u8bed\u8a00\u7684\u6587\u672c\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u5b57\u7b26\u4e32\u65b9\u6cd5\u53bb\u6389\u6362\u884c\u7b26\uff0c\u5e76\u4fdd\u7559\u591a\u8bed\u8a00\u6587\u672c\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">text = &quot;Hello\\nWorld\\n\u4f60\u597d\\n\u4e16\u754c&quot;<\/p>\n<p>cleaned_text = text.replace(&quot;\\n&quot;, &quot;&quot;)<\/p>\n<p>print(cleaned_text)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>text.replace(&quot;\\n&quot;, &quot;&quot;)<\/code> \u5c06\u5b57\u7b26\u4e32\u4e2d\u7684\u6362\u884c\u7b26\u66ff\u6362\u4e3a\u7a7a\u5b57\u7b26\u4e32\uff0c\u5e76\u4fdd\u7559\u591a\u8bed\u8a00\u6587\u672c\u3002<\/p>\n<\/p>\n<p><h3>\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u4e8c\u5341\u79cd\u65b9\u6cd5\uff0c\u6211\u4eec\u53ef\u4ee5\u7075\u6d3b\u5730\u5904\u7406\u5b57\u7b26\u4e32\u4e2d\u7684\u6362\u884c\u7b26\u3002\u65e0\u8bba\u662f\u4f7f\u7528\u5b57\u7b26\u4e32\u65b9\u6cd5\u3001\u6b63\u5219\u8868\u8fbe\u5f0f\u3001\u904d\u5386\u66ff\u6362\u3001\u8fd8\u662f\u7ed3\u5408\u591a\u79cd\u65b9\u6cd5\uff0c\u90fd\u53ef\u4ee5\u8fbe\u5230\u53bb\u6389\u6362\u884c\u7b26\u7684\u6548\u679c\u3002\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u53ef\u4ee5\u6839\u636e\u5177\u4f53\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\u6765\u5904\u7406\u5b57\u7b26\u4e32\u4e2d\u7684\u6362\u884c\u7b26\u3002\u5e0c\u671b\u8fd9\u4e9b\u65b9\u6cd5\u80fd\u591f\u5e2e\u52a9\u60a8\u66f4\u597d\u5730\u5904\u7406\u5b57\u7b26\u4e32\u4e2d\u7684\u6362\u884c\u7b26\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u5220\u9664\u5b57\u7b26\u4e32\u4e2d\u7684\u7279\u5b9a\u5b57\u7b26\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u5b57\u7b26\u4e32\u7684<code>replace()<\/code>\u65b9\u6cd5\u6765\u5220\u9664\u7279\u5b9a\u5b57\u7b26\u3002\u4f8b\u5982\uff0c\u5982\u679c\u60a8\u60f3\u8981\u5220\u9664\u5b57\u7b26\u4e32\u4e2d\u7684\u5b57\u6bcd\u201cn\u201d\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\uff1a  <\/p>\n<pre><code class=\"language-python\">my_string = &quot;banana&quot;\nnew_string = my_string.replace(&quot;n&quot;, &quot;&quot;)\nprint(new_string)  # \u8f93\u51fa\uff1abaa\n<\/code><\/pre>\n<p>\u8fd9\u79cd\u65b9\u6cd5\u7b80\u5355\u6613\u7528\uff0c\u9002\u5408\u5904\u7406\u5b57\u7b26\u5220\u9664\u7684\u60c5\u51b5\u3002<\/p>\n<p><strong>\u5728Python\u4e2d\uff0c\u5982\u4f55\u4ece\u5217\u8868\u4e2d\u79fb\u9664\u5305\u542b\u7279\u5b9a\u5b57\u7b26\u7684\u5143\u7d20\uff1f<\/strong><br \/>\u5982\u679c\u60a8\u60f3\u8981\u4ece\u5217\u8868\u4e2d\u79fb\u9664\u5305\u542b\u5b57\u6bcd\u201cn\u201d\u7684\u5143\u7d20\uff0c\u53ef\u4ee5\u4f7f\u7528\u5217\u8868\u63a8\u5bfc\u5f0f\u6765\u5b9e\u73b0\u3002\u4f8b\u5982\uff1a  <\/p>\n<pre><code class=\"language-python\">my_list = [&quot;banana&quot;, &quot;apple&quot;, &quot;orange&quot;, &quot;melon&quot;]\nfiltered_list = [fruit for fruit in my_list if &quot;n&quot; not in fruit]\nprint(filtered_list)  # \u8f93\u51fa\uff1a[&#39;apple&#39;]\n<\/code><\/pre>\n<p>\u8fd9\u79cd\u65b9\u6cd5\u80fd\u591f\u6709\u6548\u5730\u7b5b\u9009\u51fa\u4e0d\u5305\u542b\u7279\u5b9a\u5b57\u7b26\u7684\u5143\u7d20\u3002<\/p>\n<p><strong>\u5982\u4f55\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u5728Python\u4e2d\u5220\u9664\u5b57\u7b26\u4e32\u4e2d\u7684\u7279\u5b9a\u5b57\u7b26\uff1f<\/strong><br \/>\u4f7f\u7528<code>re<\/code>\u6a21\u5757\u4e2d\u7684<code>sub()<\/code>\u51fd\u6570\uff0c\u53ef\u4ee5\u901a\u8fc7\u6b63\u5219\u8868\u8fbe\u5f0f\u5220\u9664\u5b57\u7b26\u4e32\u4e2d\u7684\u7279\u5b9a\u5b57\u7b26\u3002\u4f8b\u5982\uff0c\u8981\u5220\u9664\u201cn\u201d\uff0c\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u4ee3\u7801\uff1a  <\/p>\n<pre><code class=\"language-python\">import re\n\nmy_string = &quot;banana&quot;\nnew_string = re.sub(&quot;n&quot;, &quot;&quot;, my_string)\nprint(new_string)  # \u8f93\u51fa\uff1abaa\n<\/code><\/pre>\n<p>\u8fd9\u4e2a\u65b9\u6cd5\u63d0\u4f9b\u4e86\u66f4\u5f3a\u5927\u7684\u7075\u6d3b\u6027\uff0c\u9002\u5408\u66f4\u590d\u6742\u7684\u5b57\u7b26\u5339\u914d\u548c\u5220\u9664\u9700\u6c42\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u4f7f\u7528\u5b57\u7b26\u4e32\u65b9\u6cd5\u3001\u6b63\u5219\u8868\u8fbe\u5f0f\u3001\u904d\u5386\u66ff\u6362\u7b49\u65b9\u6cd5\u53ef\u4ee5\u5c06\u5b57\u7b26\u4e32\u4e2d\u7684\u6362\u884c\u7b26\uff08\\n\uff09\u53bb\u6389\u3002 \u5176\u4e2d\uff0c\u5b57\u7b26\u4e32\u65b9\u6cd5\u662f\u4e00\u79cd\u5e38\u89c1\u4e14\u7b80 [&hellip;]","protected":false},"author":3,"featured_media":1180185,"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\/1180179"}],"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=1180179"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1180179\/revisions"}],"predecessor-version":[{"id":1180188,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1180179\/revisions\/1180188"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1180185"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1180179"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1180179"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1180179"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}