{"id":1179127,"date":"2025-01-15T18:19:31","date_gmt":"2025-01-15T10:19:31","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1179127.html"},"modified":"2025-01-15T18:19:34","modified_gmt":"2025-01-15T10:19:34","slug":"%e5%a6%82%e4%bd%95%e7%94%a8python%e7%94%9f%e6%88%90%e9%9a%8f%e6%9c%ba%e7%9f%a9%e9%98%b5","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1179127.html","title":{"rendered":"\u5982\u4f55\u7528python\u751f\u6210\u968f\u673a\u77e9\u9635"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25113637\/5da9f8d8-fbe3-4b96-aa98-0c33d4f7c135.webp\" alt=\"\u5982\u4f55\u7528python\u751f\u6210\u968f\u673a\u77e9\u9635\" \/><\/p>\n<p><p> <strong>\u7528Python\u751f\u6210\u968f\u673a\u77e9\u9635\u7684\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u5305\u62ec\u4f7f\u7528NumPy\u5e93\u3001SciPy\u5e93\u3001\u968f\u673a\u51fd\u6570\u548c\u5176\u4ed6\u4e00\u4e9b\u9ad8\u7ea7\u6280\u5de7\u3002<\/strong>\u5176\u4e2d\uff0c<strong>\u4f7f\u7528NumPy\u5e93\u751f\u6210\u968f\u673a\u77e9\u9635\u662f\u6700\u5e38\u89c1\u548c\u9ad8\u6548\u7684\u65b9\u6cd5<\/strong>\uff0c\u56e0\u4e3aNumPy\u63d0\u4f9b\u4e86\u591a\u79cd\u5185\u7f6e\u51fd\u6570\u6765\u751f\u6210\u968f\u673a\u6570\u548c\u968f\u673a\u77e9\u9635\u3002\u63a5\u4e0b\u6765\u6211\u4eec\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528NumPy\u751f\u6210\u968f\u673a\u77e9\u9635\uff0c\u5e76\u89e3\u91ca\u51e0\u79cd\u4e0d\u540c\u7684\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u4f7f\u7528NumPy\u751f\u6210\u968f\u673a\u77e9\u9635<\/h3>\n<\/p>\n<p><p>NumPy\u662fPython\u4e2d\u6700\u5e38\u7528\u7684\u6570\u503c\u8ba1\u7b97\u5e93\u4e4b\u4e00\uff0c\u5b83\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u591a\u7ef4\u6570\u7ec4\u5bf9\u8c61\u548c\u5927\u91cf\u7684\u6570\u5b66\u51fd\u6570\u3002\u8981\u4f7f\u7528NumPy\u751f\u6210\u968f\u673a\u77e9\u9635\uff0c\u9996\u5148\u9700\u8981\u5b89\u88c5NumPy\u5e93\u5e76\u5bfc\u5165\u5b83\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>1.1\u3001\u751f\u6210\u5747\u5300\u5206\u5e03\u7684\u968f\u673a\u77e9\u9635<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528<code>numpy.random.rand<\/code>\u51fd\u6570\u53ef\u4ee5\u751f\u6210\u5747\u5300\u5206\u5e03\u7684\u968f\u673a\u77e9\u9635\u3002\u8be5\u51fd\u6570\u751f\u6210\u7684\u968f\u673a\u6570\u57280\u52301\u4e4b\u95f4\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u751f\u6210\u4e00\u4e2a3x3\u7684\u5747\u5300\u5206\u5e03\u968f\u673a\u77e9\u9635<\/p>\n<p>random_matrix = np.random.rand(3, 3)<\/p>\n<p>print(random_matrix)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>1.2\u3001\u751f\u6210\u6b63\u6001\u5206\u5e03\u7684\u968f\u673a\u77e9\u9635<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528<code>numpy.random.randn<\/code>\u51fd\u6570\u53ef\u4ee5\u751f\u6210\u6b63\u6001\u5206\u5e03\uff08\u6807\u51c6\u6b63\u6001\u5206\u5e03\uff0c\u5747\u503c\u4e3a0\uff0c\u65b9\u5dee\u4e3a1\uff09\u7684\u968f\u673a\u77e9\u9635\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u751f\u6210\u4e00\u4e2a3x3\u7684\u6b63\u6001\u5206\u5e03\u968f\u673a\u77e9\u9635<\/p>\n<p>random_matrix = np.random.randn(3, 3)<\/p>\n<p>print(random_matrix)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>1.3\u3001\u751f\u6210\u81ea\u5b9a\u4e49\u5206\u5e03\u7684\u968f\u673a\u77e9\u9635<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528<code>numpy.random.uniform<\/code>\u51fd\u6570\u53ef\u4ee5\u751f\u6210\u81ea\u5b9a\u4e49\u8303\u56f4\u7684\u5747\u5300\u5206\u5e03\u968f\u673a\u77e9\u9635\uff0c<code>numpy.random.normal<\/code>\u51fd\u6570\u53ef\u4ee5\u751f\u6210\u81ea\u5b9a\u4e49\u5747\u503c\u548c\u65b9\u5dee\u7684\u6b63\u6001\u5206\u5e03\u968f\u673a\u77e9\u9635\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u751f\u6210\u4e00\u4e2a3x3\u7684\u8303\u56f4\u5728[0, 10]\u4e4b\u95f4\u7684\u5747\u5300\u5206\u5e03\u968f\u673a\u77e9\u9635<\/p>\n<p>random_matrix = np.random.uniform(0, 10, (3, 3))<\/p>\n<p>print(random_matrix)<\/p>\n<h2><strong>\u751f\u6210\u4e00\u4e2a3x3\u7684\u5747\u503c\u4e3a5\uff0c\u65b9\u5dee\u4e3a2\u7684\u6b63\u6001\u5206\u5e03\u968f\u673a\u77e9\u9635<\/strong><\/h2>\n<p>random_matrix = np.random.normal(5, 2, (3, 3))<\/p>\n<p>print(random_matrix)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e8c\u3001\u4f7f\u7528SciPy\u751f\u6210\u968f\u673a\u77e9\u9635<\/h3>\n<\/p>\n<p><p>SciPy\u662f\u53e6\u4e00\u4e2a\u5f3a\u5927\u7684\u79d1\u5b66\u8ba1\u7b97\u5e93\uff0c\u5b83\u5efa\u7acb\u5728NumPy\u57fa\u7840\u4e4b\u4e0a\uff0c\u5e76\u63d0\u4f9b\u4e86\u66f4\u591a\u7684\u7edf\u8ba1\u5206\u5e03\u51fd\u6570\u3002SciPy\u4e2d\u7684<code>scipy.stats<\/code>\u6a21\u5757\u63d0\u4f9b\u4e86\u66f4\u591a\u6837\u7684\u968f\u673a\u6570\u751f\u6210\u51fd\u6570\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from scipy.stats import uniform, norm<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2.1\u3001\u751f\u6210\u5747\u5300\u5206\u5e03\u7684\u968f\u673a\u77e9\u9635<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528<code>uniform.rvs<\/code>\u51fd\u6570\u53ef\u4ee5\u751f\u6210\u5747\u5300\u5206\u5e03\u7684\u968f\u673a\u77e9\u9635\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u751f\u6210\u4e00\u4e2a3x3\u7684\u5747\u5300\u5206\u5e03\u968f\u673a\u77e9\u9635<\/p>\n<p>random_matrix = uniform.rvs(size=(3, 3))<\/p>\n<p>print(random_matrix)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2.2\u3001\u751f\u6210\u6b63\u6001\u5206\u5e03\u7684\u968f\u673a\u77e9\u9635<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528<code>norm.rvs<\/code>\u51fd\u6570\u53ef\u4ee5\u751f\u6210\u6b63\u6001\u5206\u5e03\u7684\u968f\u673a\u77e9\u9635\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u751f\u6210\u4e00\u4e2a3x3\u7684\u6b63\u6001\u5206\u5e03\u968f\u673a\u77e9\u9635<\/p>\n<p>random_matrix = norm.rvs(size=(3, 3))<\/p>\n<p>print(random_matrix)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e09\u3001\u4f7f\u7528\u968f\u673a\u51fd\u6570\u751f\u6210\u968f\u673a\u77e9\u9635<\/h3>\n<\/p>\n<p><p>Python\u5185\u7f6e\u7684<code>random<\/code>\u6a21\u5757\u4e5f\u53ef\u4ee5\u751f\u6210\u968f\u673a\u6570\uff0c\u4f46\u5b83\u4e0d\u652f\u6301\u76f4\u63a5\u751f\u6210\u968f\u673a\u77e9\u9635\u3002\u53ef\u4ee5\u7ed3\u5408\u5217\u8868\u63a8\u5bfc\u5f0f\u6765\u751f\u6210\u968f\u673a\u77e9\u9635\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import random<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3.1\u3001\u751f\u6210\u5747\u5300\u5206\u5e03\u7684\u968f\u673a\u77e9\u9635<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528<code>random.uniform<\/code>\u51fd\u6570\u7ed3\u5408\u5217\u8868\u63a8\u5bfc\u5f0f\u53ef\u4ee5\u751f\u6210\u5747\u5300\u5206\u5e03\u7684\u968f\u673a\u77e9\u9635\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u751f\u6210\u4e00\u4e2a3x3\u7684\u5747\u5300\u5206\u5e03\u968f\u673a\u77e9\u9635<\/p>\n<p>random_matrix = [[random.uniform(0, 1) for _ in range(3)] for _ in range(3)]<\/p>\n<p>print(random_matrix)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3.2\u3001\u751f\u6210\u6b63\u6001\u5206\u5e03\u7684\u968f\u673a\u77e9\u9635<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528<code>random.gauss<\/code>\u51fd\u6570\u7ed3\u5408\u5217\u8868\u63a8\u5bfc\u5f0f\u53ef\u4ee5\u751f\u6210\u6b63\u6001\u5206\u5e03\u7684\u968f\u673a\u77e9\u9635\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u751f\u6210\u4e00\u4e2a3x3\u7684\u6b63\u6001\u5206\u5e03\u968f\u673a\u77e9\u9635<\/p>\n<p>random_matrix = [[random.gauss(0, 1) for _ in range(3)] for _ in range(3)]<\/p>\n<p>print(random_matrix)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u56db\u3001\u5176\u4ed6\u9ad8\u7ea7\u6280\u5de7<\/h3>\n<\/p>\n<p><p>\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u6709\u65f6\u9700\u8981\u751f\u6210\u7279\u5b9a\u7ed3\u6784\u7684\u968f\u673a\u77e9\u9635\uff0c\u4f8b\u5982\u5bf9\u79f0\u77e9\u9635\u3001\u7a00\u758f\u77e9\u9635\u7b49\u3002\u53ef\u4ee5\u7ed3\u5408NumPy\u548cSciPy\u7684\u51fd\u6570\u6765\u5b9e\u73b0\u8fd9\u4e9b\u9700\u6c42\u3002<\/p>\n<\/p>\n<p><h4>4.1\u3001\u751f\u6210\u5bf9\u79f0\u968f\u673a\u77e9\u9635<\/h4>\n<\/p>\n<p><p>\u5bf9\u79f0\u77e9\u9635\u5728\u8bb8\u591a\u79d1\u5b66\u8ba1\u7b97\u548c<a href=\"https:\/\/docs.pingcode.com\/ask\/59192.html\" target=\"_blank\">\u673a\u5668\u5b66\u4e60<\/a>\u5e94\u7528\u4e2d\u975e\u5e38\u5e38\u89c1\u3002\u53ef\u4ee5\u751f\u6210\u4e00\u4e2a\u968f\u673a\u77e9\u9635\uff0c\u7136\u540e\u5c06\u5176\u4e0e\u8f6c\u7f6e\u76f8\u52a0\u751f\u6210\u5bf9\u79f0\u77e9\u9635\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u751f\u6210\u4e00\u4e2a3x3\u7684\u5bf9\u79f0\u968f\u673a\u77e9\u9635<\/p>\n<p>A = np.random.rand(3, 3)<\/p>\n<p>symmetric_matrix = A + A.T<\/p>\n<p>print(symmetric_matrix)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>4.2\u3001\u751f\u6210\u7a00\u758f\u968f\u673a\u77e9\u9635<\/h4>\n<\/p>\n<p><p>\u7a00\u758f\u77e9\u9635\u5728\u5927\u89c4\u6a21\u6570\u636e\u5904\u7406\u548c\u673a\u5668\u5b66\u4e60\u4e2d\u975e\u5e38\u91cd\u8981\u3002\u53ef\u4ee5\u4f7f\u7528SciPy\u7684<code>scipy.sparse<\/code>\u6a21\u5757\u751f\u6210\u7a00\u758f\u968f\u673a\u77e9\u9635\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from scipy.sparse import random as sparse_random<\/p>\n<h2><strong>\u751f\u6210\u4e00\u4e2a3x3\u7684\u7a00\u758f\u968f\u673a\u77e9\u9635\uff0c\u7a00\u758f\u5ea6\u4e3a0.5<\/strong><\/h2>\n<p>sparse_matrix = sparse_random(3, 3, density=0.5, format=&#39;csr&#39;)<\/p>\n<p>print(sparse_matrix)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e94\u3001\u5b9e\u9645\u5e94\u7528\u793a\u4f8b<\/h3>\n<\/p>\n<p><p>\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u751f\u6210\u968f\u673a\u77e9\u9635\u7684\u9700\u6c42\u975e\u5e38\u5e7f\u6cdb\uff0c\u4f8b\u5982\u5728\u6a21\u62df\u3001\u8499\u7279\u5361\u6d1b\u65b9\u6cd5\u3001\u673a\u5668\u5b66\u4e60\u6a21\u578b\u521d\u59cb\u5316\u7b49\u65b9\u9762\u3002\u4ee5\u4e0b\u662f\u51e0\u4e2a\u5b9e\u9645\u5e94\u7528\u7684\u793a\u4f8b\u3002<\/p>\n<\/p>\n<p><h4>5.1\u3001\u751f\u6210\u7528\u4e8e\u673a\u5668\u5b66\u4e60\u6a21\u578b\u521d\u59cb\u5316\u7684\u968f\u673a\u77e9\u9635<\/h4>\n<\/p>\n<p><p>\u5728\u6df1\u5ea6\u5b66\u4e60\u4e2d\uff0c\u6a21\u578b\u53c2\u6570\u7684\u521d\u59cb\u5316\u5bf9\u8bad\u7ec3\u6548\u679c\u6709\u5f88\u5927\u5f71\u54cd\u3002\u901a\u5e38\u4f7f\u7528\u5747\u5300\u5206\u5e03\u6216\u6b63\u6001\u5206\u5e03\u7684\u968f\u673a\u6570\u8fdb\u884c\u521d\u59cb\u5316\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u751f\u6210\u4e00\u4e2a3x3\u7684\u5747\u5300\u5206\u5e03\u968f\u673a\u77e9\u9635\u7528\u4e8e\u6a21\u578b\u53c2\u6570\u521d\u59cb\u5316<\/p>\n<p>init_matrix = np.random.uniform(-0.1, 0.1, (3, 3))<\/p>\n<p>print(init_matrix)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>5.2\u3001\u751f\u6210\u7528\u4e8e\u8499\u7279\u5361\u6d1b\u6a21\u62df\u7684\u968f\u673a\u77e9\u9635<\/h4>\n<\/p>\n<p><p>\u8499\u7279\u5361\u6d1b\u6a21\u62df\u662f\u4e00\u79cd\u901a\u8fc7\u968f\u673a\u91c7\u6837\u8fdb\u884c\u6570\u503c\u8ba1\u7b97\u7684\u65b9\u6cd5\uff0c\u5e7f\u6cdb\u5e94\u7528\u4e8e\u91d1\u878d\u3001\u7269\u7406\u7b49\u9886\u57df\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u751f\u6210\u4e00\u4e2a1000x10\u7684\u6b63\u6001\u5206\u5e03\u968f\u673a\u77e9\u9635\u7528\u4e8e\u8499\u7279\u5361\u6d1b\u6a21\u62df<\/p>\n<p>monte_carlo_matrix = np.random.normal(0, 1, (1000, 10))<\/p>\n<p>print(monte_carlo_matrix)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>5.3\u3001\u751f\u6210\u7528\u4e8e\u56fe\u50cf\u5904\u7406\u7684\u968f\u673a\u77e9\u9635<\/h4>\n<\/p>\n<p><p>\u5728\u56fe\u50cf\u5904\u7406\u548c\u8ba1\u7b97\u673a\u89c6\u89c9\u4e2d\uff0c\u7ecf\u5e38\u9700\u8981\u751f\u6210\u968f\u673a\u566a\u58f0\u56fe\u50cf\u8fdb\u884c\u7b97\u6cd5\u6d4b\u8bd5\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import matplotlib.pyplot as plt<\/p>\n<h2><strong>\u751f\u6210\u4e00\u4e2a256x256\u7684\u5747\u5300\u5206\u5e03\u968f\u673a\u77e9\u9635\u4f5c\u4e3a\u566a\u58f0\u56fe\u50cf<\/strong><\/h2>\n<p>noise_image = np.random.rand(256, 256)<\/p>\n<h2><strong>\u663e\u793a\u566a\u58f0\u56fe\u50cf<\/strong><\/h2>\n<p>plt.imshow(noise_image, cmap=&#39;gray&#39;)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u793a\u4f8b\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u4f7f\u7528Python\u751f\u6210\u968f\u673a\u77e9\u9635\u7684\u65b9\u6cd5\u975e\u5e38\u4e30\u5bcc\uff0c\u5e76\u4e14\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\u5177\u6709\u5e7f\u6cdb\u7684\u7528\u9014\u3002<strong>\u901a\u8fc7\u719f\u7ec3\u638c\u63e1\u8fd9\u4e9b\u65b9\u6cd5\uff0c\u53ef\u4ee5\u66f4\u597d\u5730\u89e3\u51b3\u5b9e\u9645\u95ee\u9898\uff0c\u63d0\u9ad8\u7f16\u7a0b\u6548\u7387\u3002<\/strong><\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u4f7f\u7528Python\u751f\u6210\u4e0d\u540c\u5927\u5c0f\u7684\u968f\u673a\u77e9\u9635\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528NumPy\u5e93\u751f\u6210\u4e0d\u540c\u5927\u5c0f\u7684\u968f\u673a\u77e9\u9635\u3002\u901a\u8fc7<code>numpy.random.rand()<\/code>\u51fd\u6570\uff0c\u53ef\u4ee5\u6307\u5b9a\u77e9\u9635\u7684\u884c\u6570\u548c\u5217\u6570\u3002\u4f8b\u5982\uff0c<code>numpy.random.rand(3, 4)<\/code>\u5c06\u751f\u6210\u4e00\u4e2a3\u884c4\u5217\u7684\u968f\u673a\u77e9\u9635\uff0c\u6bcf\u4e2a\u5143\u7d20\u90fd\u662f\u57280\u52301\u4e4b\u95f4\u7684\u968f\u673a\u6570\u3002<\/p>\n<p><strong>\u662f\u5426\u53ef\u4ee5\u751f\u6210\u5305\u542b\u7279\u5b9a\u8303\u56f4\u5185\u968f\u673a\u6570\u7684\u77e9\u9635\uff1f<\/strong><br \/>\u786e\u5b9e\u53ef\u4ee5\u3002\u4f7f\u7528<code>numpy.random.randint()<\/code>\u51fd\u6570\u53ef\u4ee5\u751f\u6210\u6307\u5b9a\u8303\u56f4\u5185\u7684\u6574\u6570\u968f\u673a\u77e9\u9635\u3002\u4f8b\u5982\uff0c<code>numpy.random.randint(low=1, high=10, size=(3, 4))<\/code>\u5c06\u751f\u6210\u4e00\u4e2a\u5305\u542b1\u52309\u4e4b\u95f4\u6574\u6570\u76843\u884c4\u5217\u7684\u968f\u673a\u77e9\u9635\u3002\u82e5\u9700\u8981\u6d6e\u70b9\u6570\uff0c\u53ef\u4ee5\u5148\u751f\u6210\u968f\u673a\u6570\uff0c\u7136\u540e\u901a\u8fc7\u7f29\u653e\u548c\u504f\u79fb\u8c03\u6574\u5230\u6240\u9700\u8303\u56f4\u3002<\/p>\n<p><strong>\u5982\u4f55\u5c06\u751f\u6210\u7684\u968f\u673a\u77e9\u9635\u4fdd\u5b58\u5230\u6587\u4ef6\u4e2d\uff1f<\/strong><br \/>\u53ef\u4ee5\u4f7f\u7528NumPy\u5e93\u7684<code>numpy.savetxt()<\/code>\u51fd\u6570\u5c06\u751f\u6210\u7684\u968f\u673a\u77e9\u9635\u4fdd\u5b58\u4e3a\u6587\u672c\u6587\u4ef6\u3002\u4f8b\u5982\uff0c<code>numpy.savetxt(&#39;random_matrix.txt&#39;, random_matrix)<\/code>\u5c06\u628a\u540d\u4e3a<code>random_matrix<\/code>\u7684\u77e9\u9635\u4fdd\u5b58\u4e3a\u6587\u672c\u6587\u4ef6\u3002\u4e5f\u53ef\u4ee5\u4f7f\u7528<code>numpy.save()<\/code>\u51fd\u6570\u4fdd\u5b58\u4e3aNumPy\u7684\u4e8c\u8fdb\u5236\u683c\u5f0f\uff0c\u4fbf\u4e8e\u540e\u7eed\u52a0\u8f7d\u548c\u4f7f\u7528\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u7528Python\u751f\u6210\u968f\u673a\u77e9\u9635\u7684\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u5305\u62ec\u4f7f\u7528NumPy\u5e93\u3001SciPy\u5e93\u3001\u968f\u673a\u51fd\u6570\u548c\u5176\u4ed6\u4e00\u4e9b\u9ad8\u7ea7\u6280\u5de7\u3002\u5176\u4e2d\uff0c [&hellip;]","protected":false},"author":3,"featured_media":1179136,"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\/1179127"}],"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=1179127"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1179127\/revisions"}],"predecessor-version":[{"id":1179139,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1179127\/revisions\/1179139"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1179136"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1179127"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1179127"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1179127"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}