{"id":1084008,"date":"2025-01-08T13:03:22","date_gmt":"2025-01-08T05:03:22","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1084008.html"},"modified":"2025-01-08T13:03:24","modified_gmt":"2025-01-08T05:03:24","slug":"python%e5%a6%82%e4%bd%95%e5%b0%86%e6%95%b0%e7%bb%84%e5%86%99%e5%85%a5txt%e6%96%87%e4%bb%b6-2","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1084008.html","title":{"rendered":"python\u5982\u4f55\u5c06\u6570\u7ec4\u5199\u5165txt\u6587\u4ef6"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24194552\/a567ea40-364a-452f-82a1-2927ffc60cd4.webp\" alt=\"python\u5982\u4f55\u5c06\u6570\u7ec4\u5199\u5165txt\u6587\u4ef6\" \/><\/p>\n<p><p> <strong>\u8981\u5c06\u6570\u7ec4\u5199\u5165txt\u6587\u4ef6\uff0c\u4f7f\u7528Python\u7684\u5185\u7f6e\u51fd\u6570\u3001\u5229\u7528numpy\u5e93\u3001\u9010\u884c\u5199\u5165\u6587\u672c\u6587\u4ef6<\/strong>\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5176\u4e2d\u4e00\u79cd\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><p>\u4f7f\u7528Python\u5c06\u6570\u7ec4\u5199\u5165txt\u6587\u4ef6\u662f\u4e00\u9879\u5e38\u89c1\u7684\u4efb\u52a1\uff0c\u5c24\u5176\u662f\u5728\u6570\u636e\u5904\u7406\u548c\u5206\u6790\u8fc7\u7a0b\u4e2d\u3002\u53ef\u4ee5\u4f7f\u7528\u5185\u7f6e\u7684<code>open()<\/code>\u51fd\u6570\u548c\u5faa\u73af\u7ed3\u6784\u6765\u5b9e\u73b0\u8fd9\u4e00\u70b9\u3002\u6b64\u65b9\u6cd5\u7684\u4e3b\u8981\u6b65\u9aa4\u5305\u62ec\uff1a\u6253\u5f00\u6587\u4ef6\u3001\u904d\u5386\u6570\u7ec4\u3001\u5c06\u6bcf\u4e2a\u5143\u7d20\u5199\u5165\u6587\u4ef6\u5e76\u5173\u95ed\u6587\u4ef6\u3002\u4e0b\u9762\u662f\u8be6\u7ec6\u7684\u6b65\u9aa4\u548c\u793a\u4f8b\u4ee3\u7801\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u4f7f\u7528\u5185\u7f6e\u51fd\u6570\u5c06\u6570\u7ec4\u5199\u5165txt\u6587\u4ef6<\/h3>\n<\/p>\n<p><p>Python\u63d0\u4f9b\u4e86\u5185\u7f6e\u7684\u51fd\u6570\u6765\u5904\u7406\u6587\u4ef6\u64cd\u4f5c\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\u4ee3\u7801\uff0c\u5c55\u793a\u5982\u4f55\u4f7f\u7528\u8fd9\u4e9b\u51fd\u6570\u5c06\u6570\u7ec4\u5199\u5165txt\u6587\u4ef6\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u793a\u4f8b\u6570\u7ec4<\/p>\n<p>array = [1, 2, 3, 4, 5]<\/p>\n<h2><strong>\u6253\u5f00\u6587\u4ef6\uff0c&#39;w&#39;\u6a21\u5f0f\u8868\u793a\u5199\u5165\uff08\u5982\u679c\u6587\u4ef6\u4e0d\u5b58\u5728\u5219\u521b\u5efa\uff0c\u5b58\u5728\u5219\u6e05\u7a7a\uff09<\/strong><\/h2>\n<p>with open(&#39;output.txt&#39;, &#39;w&#39;) as file:<\/p>\n<p>    # \u904d\u5386\u6570\u7ec4<\/p>\n<p>    for element in array:<\/p>\n<p>        # \u5c06\u6570\u7ec4\u5143\u7d20\u5199\u5165\u6587\u4ef6\uff0c\u6bcf\u4e2a\u5143\u7d20\u5360\u4e00\u884c<\/p>\n<p>        file.write(f&quot;{element}\\n&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c\u4f7f\u7528<code>with open(&#39;output.txt&#39;, &#39;w&#39;) as file:<\/code>\u6253\u5f00\u6587\u4ef6\u3002<code>with<\/code>\u8bed\u53e5\u786e\u4fdd\u5728\u5199\u5165\u64cd\u4f5c\u5b8c\u6210\u540e\uff0c\u6587\u4ef6\u5c06\u88ab\u6b63\u786e\u5173\u95ed\u3002<code>file.write(f&quot;{element}\\n&quot;)<\/code>\u5c06\u6570\u7ec4\u7684\u6bcf\u4e2a\u5143\u7d20\u5199\u5165\u6587\u4ef6\uff0c\u5e76\u5728\u6bcf\u4e2a\u5143\u7d20\u540e\u6dfb\u52a0\u6362\u884c\u7b26\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u4f7f\u7528numpy\u5c06\u6570\u7ec4\u5199\u5165txt\u6587\u4ef6<\/h3>\n<\/p>\n<p><p><code>numpy<\/code>\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u6570\u503c\u8ba1\u7b97\u5e93\uff0c\u63d0\u4f9b\u4e86\u65b9\u4fbf\u7684\u65b9\u6cd5\u6765\u5904\u7406\u6570\u7ec4\u3002\u4ee5\u4e0b\u662f\u5982\u4f55\u4f7f\u7528<code>numpy.savetxt()<\/code>\u51fd\u6570\u5c06\u6570\u7ec4\u5199\u5165txt\u6587\u4ef6\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<h2><strong>\u793a\u4f8b\u4e8c\u7ef4\u6570\u7ec4<\/strong><\/h2>\n<p>array = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])<\/p>\n<h2><strong>\u5c06\u6570\u7ec4\u5199\u5165txt\u6587\u4ef6<\/strong><\/h2>\n<p>np.savetxt(&#39;output.txt&#39;, array, fmt=&#39;%d&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u6bb5\u4ee3\u7801\u4e2d\uff0c<code>np.savetxt(&#39;output.txt&#39;, array, fmt=&#39;%d&#39;)<\/code>\u5c06\u6570\u7ec4\u5199\u5165\u6587\u4ef6\u3002<code>fmt=&#39;%d&#39;<\/code>\u6307\u5b9a\u5143\u7d20\u7684\u683c\u5f0f\u4e3a\u6574\u6570\u3002\u5982\u679c\u5e0c\u671b\u8f93\u51fa\u6d6e\u70b9\u6570\uff0c\u53ef\u4ee5\u4f7f\u7528<code>&#39;%.2f&#39;<\/code>\u7b49\u683c\u5f0f\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u9010\u884c\u5199\u5165\u6587\u672c\u6587\u4ef6<\/h3>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u53ef\u80fd\u9700\u8981\u9010\u884c\u5199\u5165\u6570\u7ec4\u5230\u6587\u672c\u6587\u4ef6\u3002\u4ee5\u4e0b\u793a\u4f8b\u5c55\u793a\u5982\u4f55\u5b9e\u73b0\u8fd9\u4e00\u70b9\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u793a\u4f8b\u4e8c\u7ef4\u6570\u7ec4<\/p>\n<p>array = [<\/p>\n<p>    [1, 2, 3],<\/p>\n<p>    [4, 5, 6],<\/p>\n<p>    [7, 8, 9]<\/p>\n<p>]<\/p>\n<h2><strong>\u6253\u5f00\u6587\u4ef6<\/strong><\/h2>\n<p>with open(&#39;output.txt&#39;, &#39;w&#39;) as file:<\/p>\n<p>    # \u904d\u5386\u6570\u7ec4\u7684\u6bcf\u4e00\u884c<\/p>\n<p>    for row in array:<\/p>\n<p>        # \u5c06\u6bcf\u884c\u5143\u7d20\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\uff0c\u5e76\u7528\u7a7a\u683c\u5206\u9694<\/p>\n<p>        line = &#39; &#39;.join(map(str, row))<\/p>\n<p>        # \u5199\u5165\u6587\u4ef6\uff0c\u5e76\u6dfb\u52a0\u6362\u884c\u7b26<\/p>\n<p>        file.write(line + &#39;\\n&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u56db\u3001\u5c06\u6570\u7ec4\u5199\u5165txt\u6587\u4ef6\u5e76\u8bfb\u53d6<\/h3>\n<\/p>\n<p><p>\u6709\u65f6\u9700\u8981\u5c06\u6570\u7ec4\u5199\u5165txt\u6587\u4ef6\u540e\uff0c\u518d\u4ece\u6587\u4ef6\u4e2d\u8bfb\u53d6\u3002\u4ee5\u4e0b\u662f\u5b9e\u73b0\u8fd9\u4e00\u8fc7\u7a0b\u7684\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u793a\u4f8b\u6570\u7ec4<\/p>\n<p>array = [10, 20, 30, 40, 50]<\/p>\n<h2><strong>\u5199\u5165\u6587\u4ef6<\/strong><\/h2>\n<p>with open(&#39;output.txt&#39;, &#39;w&#39;) as file:<\/p>\n<p>    for element in array:<\/p>\n<p>        file.write(f&quot;{element}\\n&quot;)<\/p>\n<h2><strong>\u8bfb\u53d6\u6587\u4ef6<\/strong><\/h2>\n<p>with open(&#39;output.txt&#39;, &#39;r&#39;) as file:<\/p>\n<p>    # \u8bfb\u53d6\u6bcf\u4e00\u884c\uff0c\u5e76\u53bb\u9664\u6362\u884c\u7b26<\/p>\n<p>    content = [int(line.strip()) for line in file]<\/p>\n<p>print(content)  # \u8f93\u51fa: [10, 20, 30, 40, 50]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e94\u3001\u5c06\u591a\u7ef4\u6570\u7ec4\u5199\u5165txt\u6587\u4ef6<\/h3>\n<\/p>\n<p><p>\u591a\u7ef4\u6570\u7ec4\uff08\u5982\u4e8c\u7ef4\u6570\u7ec4\uff09\u53ef\u4ee5\u4f7f\u7528\u7c7b\u4f3c\u7684\u65b9\u6cd5\u5199\u5165txt\u6587\u4ef6\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u793a\u4f8b\u4e8c\u7ef4\u6570\u7ec4<\/p>\n<p>array = [<\/p>\n<p>    [1.1, 2.2, 3.3],<\/p>\n<p>    [4.4, 5.5, 6.6],<\/p>\n<p>    [7.7, 8.8, 9.9]<\/p>\n<p>]<\/p>\n<h2><strong>\u6253\u5f00\u6587\u4ef6<\/strong><\/h2>\n<p>with open(&#39;output.txt&#39;, &#39;w&#39;) as file:<\/p>\n<p>    for row in array:<\/p>\n<p>        # \u5c06\u6bcf\u884c\u5143\u7d20\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\uff0c\u5e76\u7528\u7a7a\u683c\u5206\u9694<\/p>\n<p>        line = &#39; &#39;.join(map(str, row))<\/p>\n<p>        # \u5199\u5165\u6587\u4ef6\uff0c\u5e76\u6dfb\u52a0\u6362\u884c\u7b26<\/p>\n<p>        file.write(line + &#39;\\n&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c<code>map(str, row)<\/code>\u5c06\u6570\u7ec4\u5143\u7d20\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\uff0c<code>&#39; &#39;.join()<\/code>\u5c06\u5b83\u4eec\u7528\u7a7a\u683c\u5206\u9694\uff0c\u5f62\u6210\u4e00\u884c\u5b57\u7b26\u4e32\uff0c\u7136\u540e\u5199\u5165\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><h3>\u516d\u3001\u4f7f\u7528\u81ea\u5b9a\u4e49\u5206\u9694\u7b26\u5199\u5165txt\u6587\u4ef6<\/h3>\n<\/p>\n<p><p>\u6709\u65f6\u5019\u9700\u8981\u4f7f\u7528\u7279\u5b9a\u7684\u5206\u9694\u7b26\uff08\u5982\u9017\u53f7\u3001\u5206\u53f7\uff09\u5c06\u6570\u7ec4\u5143\u7d20\u5199\u5165txt\u6587\u4ef6\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u793a\u4f8b\u6570\u7ec4<\/p>\n<p>array = [100, 200, 300, 400, 500]<\/p>\n<h2><strong>\u5b9a\u4e49\u5206\u9694\u7b26<\/strong><\/h2>\n<p>separator = &#39;, &#39;<\/p>\n<h2><strong>\u6253\u5f00\u6587\u4ef6<\/strong><\/h2>\n<p>with open(&#39;output.txt&#39;, &#39;w&#39;) as file:<\/p>\n<p>    # \u5c06\u6570\u7ec4\u5143\u7d20\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\uff0c\u5e76\u7528\u5206\u9694\u7b26\u8fde\u63a5<\/p>\n<p>    line = separator.join(map(str, array))<\/p>\n<p>    # \u5199\u5165\u6587\u4ef6<\/p>\n<p>    file.write(line)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c<code>separator = &#39;, &#39;<\/code>\u5b9a\u4e49\u4e86\u9017\u53f7\u548c\u7a7a\u683c\u4f5c\u4e3a\u5206\u9694\u7b26\uff0c<code>separator.join(map(str, array))<\/code>\u5c06\u6570\u7ec4\u5143\u7d20\u7528\u5206\u9694\u7b26\u8fde\u63a5\uff0c\u5e76\u5199\u5165\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><h3>\u4e03\u3001\u5c06\u6570\u7ec4\u548c\u5176\u4ed6\u6570\u636e\u5199\u5165\u540c\u4e00\u4e2atxt\u6587\u4ef6<\/h3>\n<\/p>\n<p><p>\u6709\u65f6\u5019\u9700\u8981\u5c06\u6570\u7ec4\u548c\u5176\u4ed6\u7c7b\u578b\u7684\u6570\u636e\uff08\u5982\u5b57\u7b26\u4e32\u3001\u5b57\u5178\uff09\u5199\u5165\u540c\u4e00\u4e2atxt\u6587\u4ef6\u3002\u4ee5\u4e0b\u662f\u5b9e\u73b0\u8fd9\u4e00\u8fc7\u7a0b\u7684\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u793a\u4f8b\u6570\u7ec4\u548c\u5176\u4ed6\u6570\u636e<\/p>\n<p>array = [42, 84, 168]<\/p>\n<p>message = &quot;This is an example message.&quot;<\/p>\n<p>data_dict = {&quot;key1&quot;: &quot;value1&quot;, &quot;key2&quot;: &quot;value2&quot;}<\/p>\n<h2><strong>\u6253\u5f00\u6587\u4ef6<\/strong><\/h2>\n<p>with open(&#39;output.txt&#39;, &#39;w&#39;) as file:<\/p>\n<p>    # \u5199\u5165\u6570\u7ec4<\/p>\n<p>    file.write(&quot;Array:\\n&quot;)<\/p>\n<p>    for element in array:<\/p>\n<p>        file.write(f&quot;{element}\\n&quot;)<\/p>\n<p>    # \u5199\u5165\u6d88\u606f<\/p>\n<p>    file.write(&quot;\\nMessage:\\n&quot;)<\/p>\n<p>    file.write(message + &#39;\\n&#39;)<\/p>\n<p>    # \u5199\u5165\u5b57\u5178<\/p>\n<p>    file.write(&quot;\\nDictionary:\\n&quot;)<\/p>\n<p>    for key, value in data_dict.items():<\/p>\n<p>        file.write(f&quot;{key}: {value}\\n&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c<code>file.write()<\/code>\u65b9\u6cd5\u88ab\u591a\u6b21\u8c03\u7528\uff0c\u4ee5\u4fbf\u5c06\u4e0d\u540c\u7c7b\u578b\u7684\u6570\u636e\u5199\u5165\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><p>\u603b\u7ed3\u8d77\u6765\uff0cPython\u63d0\u4f9b\u4e86\u591a\u79cd\u65b9\u6cd5\u5c06\u6570\u7ec4\u5199\u5165txt\u6587\u4ef6\uff0c\u53ef\u4ee5\u6839\u636e\u5177\u4f53\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\u3002\u65e0\u8bba\u662f\u4f7f\u7528\u5185\u7f6e\u51fd\u6570\u3001<code>numpy<\/code>\u5e93\uff0c\u8fd8\u662f\u9010\u884c\u5199\u5165\uff0c\u90fd\u80fd\u65b9\u4fbf\u5730\u5b9e\u73b0\u6570\u636e\u7684\u5b58\u50a8\u548c\u5904\u7406\u3002<\/p>\n<\/p>\n<p><p>\u5e0c\u671b\u672c\u6587\u80fd\u591f\u5e2e\u52a9\u4f60\u66f4\u597d\u5730\u7406\u89e3\u548c\u638c\u63e1Python\u4e2d\u6570\u7ec4\u5199\u5165txt\u6587\u4ef6\u7684\u65b9\u6cd5\u548c\u6280\u5de7\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u5c06\u6570\u7ec4\u6570\u636e\u4fdd\u5b58\u4e3aTXT\u6587\u4ef6\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u5185\u7f6e\u7684\u6587\u4ef6\u64cd\u4f5c\u529f\u80fd\u5c06\u6570\u7ec4\u5199\u5165TXT\u6587\u4ef6\u3002\u9996\u5148\uff0c\u901a\u8fc7<code>open()<\/code>\u51fd\u6570\u6253\u5f00\u4e00\u4e2a\u6587\u4ef6\u5e76\u6307\u5b9a\u5199\u5165\u6a21\u5f0f\u3002\u63a5\u7740\uff0c\u53ef\u4ee5\u4f7f\u7528<code>numpy<\/code>\u5e93\u7684<code>numpy.savetxt()<\/code>\u51fd\u6570\uff0c\u6216\u8005\u4f7f\u7528\u7b80\u5355\u7684\u5faa\u73af\u5c06\u6570\u7ec4\u9010\u884c\u5199\u5165\u6587\u4ef6\u3002\u786e\u4fdd\u5728\u5b8c\u6210\u540e\u5173\u95ed\u6587\u4ef6\u4ee5\u4fdd\u5b58\u66f4\u6539\u3002<\/p>\n<p><strong>\u4f7f\u7528numpy\u5e93\u5199\u5165TXT\u6587\u4ef6\u7684\u4f18\u52bf\u662f\u4ec0\u4e48\uff1f<\/strong><br \/>\u4f7f\u7528<code>numpy<\/code>\u5e93\u53ef\u4ee5\u65b9\u4fbf\u5730\u5c06\u6570\u7ec4\u5199\u5165TXT\u6587\u4ef6\uff0c\u5b83\u652f\u6301\u591a\u79cd\u683c\u5f0f\u7684\u8f93\u51fa\uff0c\u4e14\u80fd\u5904\u7406\u5927\u6570\u636e\u96c6\u3002<code>numpy.savetxt()<\/code>\u51fd\u6570\u63d0\u4f9b\u4e86\u7075\u6d3b\u7684\u53c2\u6570\u8bbe\u7f6e\uff0c\u7528\u6237\u53ef\u4ee5\u8f7b\u677e\u9009\u62e9\u5206\u9694\u7b26\u3001\u683c\u5f0f\u5316\u65b9\u5f0f\u7b49\uff0c\u4f7f\u5f97\u6570\u636e\u4fdd\u5b58\u8fc7\u7a0b\u66f4\u52a0\u9ad8\u6548\u548c\u7b80\u4fbf\u3002<\/p>\n<p><strong>\u5728\u5199\u5165TXT\u6587\u4ef6\u65f6\uff0c\u5982\u4f55\u5904\u7406\u591a\u7ef4\u6570\u7ec4\uff1f<\/strong><br \/>\u5904\u7406\u591a\u7ef4\u6570\u7ec4\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528<code>numpy.savetxt()<\/code>\u51fd\u6570\u8fdb\u884c\u4fdd\u5b58\u3002\u6b64\u51fd\u6570\u5141\u8bb8\u7528\u6237\u901a\u8fc7\u8bbe\u7f6e<code>delimiter<\/code>\u53c2\u6570\u6765\u5b9a\u4e49\u6570\u636e\u4e4b\u95f4\u7684\u5206\u9694\u7b26\u3002\u5982\u679c\u9700\u8981\u5c06\u6bcf\u4e00\u7ef4\u7684\u6570\u636e\u4ee5\u4e0d\u540c\u683c\u5f0f\u4fdd\u5b58\uff0c\u53ef\u4ee5\u5148\u5c06\u591a\u7ef4\u6570\u7ec4\u8f6c\u6362\u4e3a\u4e00\u7ef4\u6570\u7ec4\uff0c\u6216\u4f7f\u7528<code>reshape()<\/code>\u51fd\u6570\u8c03\u6574\u5176\u5f62\u72b6\uff0c\u518d\u8fdb\u884c\u5199\u5165\u3002<\/p>\n<p><strong>\u5728\u5199\u5165\u6570\u7ec4\u6570\u636e\u540e\uff0c\u5982\u4f55\u9a8c\u8bc1\u6570\u636e\u662f\u5426\u6b63\u786e\u4fdd\u5b58\uff1f<\/strong><br \/>\u9a8c\u8bc1\u6570\u636e\u662f\u5426\u6b63\u786e\u4fdd\u5b58\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u8bfb\u53d6TXT\u6587\u4ef6\u5e76\u4e0e\u539f\u6570\u7ec4\u8fdb\u884c\u6bd4\u8f83\u3002\u4f7f\u7528<code>numpy.loadtxt()<\/code>\u51fd\u6570\u53ef\u4ee5\u8f7b\u677e\u52a0\u8f7d\u4fdd\u5b58\u7684\u6587\u4ef6\uff0c\u5e76\u5c06\u5176\u8f6c\u6362\u4e3a\u6570\u7ec4\u3002\u901a\u8fc7\u6bd4\u8f83\u4e24\u4e2a\u6570\u7ec4\u7684\u503c\uff0c\u53ef\u4ee5\u786e\u8ba4\u6570\u636e\u662f\u5426\u5982\u9884\u671f\u4fdd\u5b58\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u8981\u5c06\u6570\u7ec4\u5199\u5165txt\u6587\u4ef6\uff0c\u4f7f\u7528Python\u7684\u5185\u7f6e\u51fd\u6570\u3001\u5229\u7528numpy\u5e93\u3001\u9010\u884c\u5199\u5165\u6587\u672c\u6587\u4ef6\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5176\u4e2d\u4e00\u79cd [&hellip;]","protected":false},"author":3,"featured_media":1084013,"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\/1084008"}],"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=1084008"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1084008\/revisions"}],"predecessor-version":[{"id":1084016,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1084008\/revisions\/1084016"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1084013"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1084008"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1084008"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1084008"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}