{"id":1177630,"date":"2025-01-15T18:00:15","date_gmt":"2025-01-15T10:00:15","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1177630.html"},"modified":"2025-01-15T18:00:17","modified_gmt":"2025-01-15T10:00:17","slug":"python%e5%a6%82%e4%bd%95%e5%bb%ba%e7%ab%8b%e9%9a%8f%e6%9c%ba%e6%95%b0","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1177630.html","title":{"rendered":"Python\u5982\u4f55\u5efa\u7acb\u968f\u673a\u6570"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25112516\/cff94f03-e570-4c33-b8b3-8524202b785b.webp\" alt=\"Python\u5982\u4f55\u5efa\u7acb\u968f\u673a\u6570\" \/><\/p>\n<p><p> Python\u5982\u4f55\u5efa\u7acb\u968f\u673a\u6570\uff1f<strong>\u4f7f\u7528random\u6a21\u5757\u3001\u4f7f\u7528numpy\u5e93\u3001\u4f7f\u7528secrets\u6a21\u5757\u3001\u4f7f\u7528os\u6a21\u5757<\/strong>\u3002\u5176\u4e2d\uff0c\u4f7f\u7528random\u6a21\u5757\u662f\u6700\u5e38\u89c1\u548c\u65b9\u4fbf\u7684\u65b9\u6cd5\u3002random\u6a21\u5757\u63d0\u4f9b\u4e86\u591a\u79cd\u751f\u6210\u968f\u673a\u6570\u7684\u65b9\u6cd5\uff0c\u5982\u968f\u673a\u6574\u6570\u3001\u968f\u673a\u6d6e\u70b9\u6570\u3001\u4ece\u5e8f\u5217\u4e2d\u968f\u673a\u9009\u62e9\u5143\u7d20\u7b49\u3002<\/p>\n<\/p>\n<p><p>random\u6a21\u5757\u5305\u542b\u4e86\u4e00\u4e9b\u5e38\u7528\u7684\u51fd\u6570\uff0c\u4ee5\u4e0b\u662f\u51e0\u4e2a\u5173\u952e\u51fd\u6570\u53ca\u5176\u7528\u9014\uff1a<\/p>\n<\/p>\n<ol>\n<li><strong>random()<\/strong>\uff1a\u751f\u6210\u4e00\u4e2a0\u52301\u4e4b\u95f4\u7684\u968f\u673a\u6d6e\u70b9\u6570\u3002<\/li>\n<li><strong>randint(a, b)<\/strong>\uff1a\u751f\u6210\u4e00\u4e2aa\u5230b\u4e4b\u95f4\u7684\u968f\u673a\u6574\u6570\uff0c\u5305\u542ba\u548cb\u3002<\/li>\n<li><strong>uniform(a, b)<\/strong>\uff1a\u751f\u6210\u4e00\u4e2aa\u5230b\u4e4b\u95f4\u7684\u968f\u673a\u6d6e\u70b9\u6570\u3002<\/li>\n<li><strong>choice(seq)<\/strong>\uff1a\u4ece\u5e8f\u5217seq\u4e2d\u968f\u673a\u9009\u62e9\u4e00\u4e2a\u5143\u7d20\u3002<\/li>\n<li><strong>shuffle(seq)<\/strong>\uff1a\u968f\u673a\u6253\u4e71\u5e8f\u5217seq\u3002<\/li>\n<li><strong>sample(seq, k)<\/strong>\uff1a\u4ece\u5e8f\u5217seq\u4e2d\u968f\u673a\u9009\u62e9k\u4e2a\u5143\u7d20\u3002<\/li>\n<\/ol>\n<p><p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u8be6\u7ec6\u4ecb\u7ecdPython\u4e2d\u5982\u4f55\u4f7f\u7528\u8fd9\u4e9b\u6a21\u5757\u548c\u51fd\u6570\u6765\u751f\u6210\u968f\u673a\u6570\u3002<\/p>\n<\/p>\n<h2><strong>\u4e00\u3001\u4f7f\u7528random\u6a21\u5757<\/strong><\/h2>\n<p><h2>1.1 random()\u51fd\u6570<\/h2>\n<\/p>\n<p><p>random()\u51fd\u6570\u7528\u4e8e\u751f\u6210\u4e00\u4e2a0\u52301\u4e4b\u95f4\u7684\u968f\u673a\u6d6e\u70b9\u6570\u3002\u8fd9\u4e2a\u51fd\u6570\u6ca1\u6709\u53c2\u6570\uff0c\u8c03\u7528\u65f6\u76f4\u63a5\u8fd4\u56de\u4e00\u4e2a\u968f\u673a\u6d6e\u70b9\u6570\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import random<\/p>\n<p>print(random.random())<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>1.2 randint()\u51fd\u6570<\/h2>\n<\/p>\n<p><p>randint()\u51fd\u6570\u7528\u4e8e\u751f\u6210\u4e00\u4e2a\u6307\u5b9a\u8303\u56f4\u5185\u7684\u968f\u673a\u6574\u6570\u3002\u8fd9\u4e2a\u51fd\u6570\u6709\u4e24\u4e2a\u53c2\u6570\uff0c\u5206\u522b\u662f\u8303\u56f4\u7684\u8d77\u59cb\u503c\u548c\u7ed3\u675f\u503c\uff0c\u5305\u542b\u8d77\u59cb\u503c\u548c\u7ed3\u675f\u503c\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import random<\/p>\n<p>print(random.randint(1, 10))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>1.3 uniform()\u51fd\u6570<\/h2>\n<\/p>\n<p><p>uniform()\u51fd\u6570\u7528\u4e8e\u751f\u6210\u4e00\u4e2a\u6307\u5b9a\u8303\u56f4\u5185\u7684\u968f\u673a\u6d6e\u70b9\u6570\u3002\u8fd9\u4e2a\u51fd\u6570\u6709\u4e24\u4e2a\u53c2\u6570\uff0c\u5206\u522b\u662f\u8303\u56f4\u7684\u8d77\u59cb\u503c\u548c\u7ed3\u675f\u503c\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import random<\/p>\n<p>print(random.uniform(1.5, 5.5))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>1.4 choice()\u51fd\u6570<\/h2>\n<\/p>\n<p><p>choice()\u51fd\u6570\u7528\u4e8e\u4ece\u4e00\u4e2a\u5e8f\u5217\u4e2d\u968f\u673a\u9009\u62e9\u4e00\u4e2a\u5143\u7d20\u3002\u8fd9\u4e2a\u51fd\u6570\u6709\u4e00\u4e2a\u53c2\u6570\uff0c\u8868\u793a\u8981\u9009\u62e9\u7684\u5e8f\u5217\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import random<\/p>\n<p>my_list = [1, 2, 3, 4, 5]<\/p>\n<p>print(random.choice(my_list))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>1.5 shuffle()\u51fd\u6570<\/h2>\n<\/p>\n<p><p>shuffle()\u51fd\u6570\u7528\u4e8e\u5c06\u4e00\u4e2a\u5e8f\u5217\u4e2d\u7684\u5143\u7d20\u968f\u673a\u6253\u4e71\u3002\u8fd9\u4e2a\u51fd\u6570\u6709\u4e00\u4e2a\u53c2\u6570\uff0c\u8868\u793a\u8981\u6253\u4e71\u7684\u5e8f\u5217\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import random<\/p>\n<p>my_list = [1, 2, 3, 4, 5]<\/p>\n<p>random.shuffle(my_list)<\/p>\n<p>print(my_list)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>1.6 sample()\u51fd\u6570<\/h2>\n<\/p>\n<p><p>sample()\u51fd\u6570\u7528\u4e8e\u4ece\u4e00\u4e2a\u5e8f\u5217\u4e2d\u968f\u673a\u9009\u62e9\u6307\u5b9a\u6570\u91cf\u7684\u5143\u7d20\u3002\u8fd9\u4e2a\u51fd\u6570\u6709\u4e24\u4e2a\u53c2\u6570\uff0c\u5206\u522b\u662f\u8981\u9009\u62e9\u7684\u5e8f\u5217\u548c\u8981\u9009\u62e9\u7684\u5143\u7d20\u6570\u91cf\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import random<\/p>\n<p>my_list = [1, 2, 3, 4, 5]<\/p>\n<p>print(random.sample(my_list, 3))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<h2><strong>\u4e8c\u3001\u4f7f\u7528numpy\u5e93<\/strong><\/h2>\n<p><h2>2.1 numpy.random\u6a21\u5757<\/h2>\n<\/p>\n<p><p>numpy\u5e93\u4e2d\u7684random\u6a21\u5757\u63d0\u4f9b\u4e86\u66f4\u591a\u751f\u6210\u968f\u673a\u6570\u7684\u65b9\u6cd5\uff0c\u5c24\u5176\u662f\u5728\u751f\u6210\u591a\u7ef4\u6570\u7ec4\u548c\u8fdb\u884c\u79d1\u5b66\u8ba1\u7b97\u65f6\u975e\u5e38\u6709\u7528\u3002<\/p>\n<\/p>\n<p><h3>2.1.1 rand()\u51fd\u6570<\/h3>\n<\/p>\n<p><p>rand()\u51fd\u6570\u7528\u4e8e\u751f\u6210\u6307\u5b9a\u5f62\u72b6\u7684\u968f\u673a\u6d6e\u70b9\u6570\u6570\u7ec4\uff0c\u6570\u7ec4\u4e2d\u7684\u6bcf\u4e2a\u5143\u7d20\u90fd\u57280\u52301\u4e4b\u95f4\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<p>print(np.random.rand(3, 2))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2.1.2 randint()\u51fd\u6570<\/h3>\n<\/p>\n<p><p>randint()\u51fd\u6570\u7528\u4e8e\u751f\u6210\u6307\u5b9a\u8303\u56f4\u5185\u7684\u968f\u673a\u6574\u6570\u6570\u7ec4\u3002\u8fd9\u4e2a\u51fd\u6570\u6709\u4e09\u4e2a\u53c2\u6570\uff0c\u5206\u522b\u662f\u8303\u56f4\u7684\u8d77\u59cb\u503c\u3001\u7ed3\u675f\u503c\u548c\u6570\u7ec4\u7684\u5f62\u72b6\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<p>print(np.random.randint(1, 10, (2, 3)))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2.1.3 uniform()\u51fd\u6570<\/h3>\n<\/p>\n<p><p>uniform()\u51fd\u6570\u7528\u4e8e\u751f\u6210\u6307\u5b9a\u8303\u56f4\u5185\u7684\u968f\u673a\u6d6e\u70b9\u6570\u6570\u7ec4\u3002\u8fd9\u4e2a\u51fd\u6570\u6709\u4e09\u4e2a\u53c2\u6570\uff0c\u5206\u522b\u662f\u8303\u56f4\u7684\u8d77\u59cb\u503c\u3001\u7ed3\u675f\u503c\u548c\u6570\u7ec4\u7684\u5f62\u72b6\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<p>print(np.random.uniform(1.5, 5.5, (2, 3)))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2.1.4 choice()\u51fd\u6570<\/h3>\n<\/p>\n<p><p>choice()\u51fd\u6570\u7528\u4e8e\u4ece\u4e00\u4e2a\u5e8f\u5217\u4e2d\u968f\u673a\u9009\u62e9\u6307\u5b9a\u6570\u91cf\u7684\u5143\u7d20\uff0c\u5e76\u8fd4\u56de\u4e00\u4e2a\u6570\u7ec4\u3002\u8fd9\u4e2a\u51fd\u6570\u6709\u4e24\u4e2a\u53c2\u6570\uff0c\u5206\u522b\u662f\u8981\u9009\u62e9\u7684\u5e8f\u5217\u548c\u8981\u9009\u62e9\u7684\u5143\u7d20\u6570\u91cf\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<p>my_array = np.array([1, 2, 3, 4, 5])<\/p>\n<p>print(np.random.choice(my_array, 3))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2.1.5 shuffle()\u51fd\u6570<\/h3>\n<\/p>\n<p><p>shuffle()\u51fd\u6570\u7528\u4e8e\u5c06\u4e00\u4e2a\u6570\u7ec4\u4e2d\u7684\u5143\u7d20\u968f\u673a\u6253\u4e71\u3002\u8fd9\u4e2a\u51fd\u6570\u6709\u4e00\u4e2a\u53c2\u6570\uff0c\u8868\u793a\u8981\u6253\u4e71\u7684\u6570\u7ec4\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<p>my_array = np.array([1, 2, 3, 4, 5])<\/p>\n<p>np.random.shuffle(my_array)<\/p>\n<p>print(my_array)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<h2><strong>\u4e09\u3001\u4f7f\u7528secrets\u6a21\u5757<\/strong><\/h2>\n<p><p>secrets\u6a21\u5757\u7528\u4e8e\u751f\u6210\u5b89\u5168\u7684\u968f\u673a\u6570\uff0c\u9002\u7528\u4e8e\u9700\u8981\u5bc6\u7801\u6216\u5176\u4ed6\u5b89\u5168\u6570\u636e\u7684\u573a\u666f\u3002<\/p>\n<\/p>\n<p><h2>3.1 token_bytes()\u51fd\u6570<\/h2>\n<\/p>\n<p><p>token_bytes()\u51fd\u6570\u7528\u4e8e\u751f\u6210\u6307\u5b9a\u957f\u5ea6\u7684\u968f\u673a\u5b57\u8282\u4e32\u3002\u8fd9\u4e2a\u51fd\u6570\u6709\u4e00\u4e2a\u53c2\u6570\uff0c\u8868\u793a\u5b57\u8282\u4e32\u7684\u957f\u5ea6\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import secrets<\/p>\n<p>print(secrets.token_bytes(16))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>3.2 token_hex()\u51fd\u6570<\/h2>\n<\/p>\n<p><p>token_hex()\u51fd\u6570\u7528\u4e8e\u751f\u6210\u6307\u5b9a\u957f\u5ea6\u7684\u968f\u673a\u5341\u516d\u8fdb\u5236\u5b57\u7b26\u4e32\u3002\u8fd9\u4e2a\u51fd\u6570\u6709\u4e00\u4e2a\u53c2\u6570\uff0c\u8868\u793a\u5b57\u7b26\u4e32\u7684\u957f\u5ea6\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import secrets<\/p>\n<p>print(secrets.token_hex(16))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>3.3 token_url<a href=\"https:\/\/docs.pingcode.com\/agile\/agile-at-scale\/what-is-safe\" target=\"_blank\">SAFe<\/a>()\u51fd\u6570<\/h2>\n<\/p>\n<p><p>token_urlsafe()\u51fd\u6570\u7528\u4e8e\u751f\u6210\u6307\u5b9a\u957f\u5ea6\u7684\u968f\u673aURL\u5b89\u5168\u5b57\u7b26\u4e32\u3002\u8fd9\u4e2a\u51fd\u6570\u6709\u4e00\u4e2a\u53c2\u6570\uff0c\u8868\u793a\u5b57\u7b26\u4e32\u7684\u957f\u5ea6\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import secrets<\/p>\n<p>print(secrets.token_urlsafe(16))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<h2><strong>\u56db\u3001\u4f7f\u7528os\u6a21\u5757<\/strong><\/h2>\n<p><p>os\u6a21\u5757\u63d0\u4f9b\u4e86\u4e0e\u64cd\u4f5c\u7cfb\u7edf\u76f8\u5173\u7684\u529f\u80fd\uff0c\u5176\u4e2d\u5305\u62ec\u751f\u6210\u968f\u673a\u6570\u7684\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><h2>4.1 urandom()\u51fd\u6570<\/h2>\n<\/p>\n<p><p>urandom()\u51fd\u6570\u7528\u4e8e\u751f\u6210\u6307\u5b9a\u957f\u5ea6\u7684\u968f\u673a\u5b57\u8282\u4e32\u3002\u8fd9\u4e2a\u51fd\u6570\u6709\u4e00\u4e2a\u53c2\u6570\uff0c\u8868\u793a\u5b57\u8282\u4e32\u7684\u957f\u5ea6\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import os<\/p>\n<p>print(os.urandom(16))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<h2><strong>\u4e94\u3001\u603b\u7ed3<\/strong><\/h2>\n<p><p>\u7efc\u4e0a\u6240\u8ff0\uff0cPython\u63d0\u4f9b\u4e86\u591a\u79cd\u751f\u6210\u968f\u673a\u6570\u7684\u65b9\u6cd5\uff0c<strong>\u4f7f\u7528random\u6a21\u5757\u3001\u4f7f\u7528numpy\u5e93\u3001\u4f7f\u7528secrets\u6a21\u5757\u3001\u4f7f\u7528os\u6a21\u5757<\/strong>\u3002\u5176\u4e2d\uff0crandom\u6a21\u5757\u662f\u6700\u5e38\u7528\u548c\u65b9\u4fbf\u7684\u65b9\u6cd5\uff0c\u9002\u7528\u4e8e\u5927\u591a\u6570\u5e38\u89c1\u7684\u968f\u673a\u6570\u751f\u6210\u9700\u6c42\u3002numpy\u5e93\u5219\u9002\u7528\u4e8e\u9700\u8981\u751f\u6210\u591a\u7ef4\u6570\u7ec4\u548c\u8fdb\u884c\u79d1\u5b66\u8ba1\u7b97\u7684\u573a\u666f\u3002secrets\u6a21\u5757\u9002\u7528\u4e8e\u9700\u8981\u751f\u6210\u5b89\u5168\u968f\u673a\u6570\u7684\u573a\u666f\uff0c\u5982\u5bc6\u7801\u548c\u4ee4\u724c\u3002os\u6a21\u5757\u63d0\u4f9b\u4e86\u4e0e\u64cd\u4f5c\u7cfb\u7edf\u76f8\u5173\u7684\u968f\u673a\u6570\u751f\u6210\u65b9\u6cd5\u3002\u6839\u636e\u5177\u4f53\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\uff0c\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u66f4\u597d\u5730\u751f\u6210\u968f\u673a\u6570\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u751f\u6210\u968f\u673a\u6570\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u5185\u7f6e\u7684<code>random<\/code>\u6a21\u5757\u6765\u751f\u6210\u968f\u673a\u6570\u3002\u901a\u8fc7\u8c03\u7528\u4e0d\u540c\u7684\u51fd\u6570\uff0c\u4f60\u53ef\u4ee5\u751f\u6210\u6d6e\u70b9\u6570\u3001\u6574\u6570\u4ee5\u53ca\u9009\u62e9\u968f\u673a\u5143\u7d20\u7b49\u3002\u4f8b\u5982\uff0c\u4f7f\u7528<code>random.random()<\/code>\u53ef\u4ee5\u751f\u6210\u4e00\u4e2a0\u52301\u4e4b\u95f4\u7684\u968f\u673a\u6d6e\u70b9\u6570\uff0c\u800c<code>random.randint(a, b)<\/code>\u4f1a\u751f\u6210\u4e00\u4e2a\u5728a\u5230b\u4e4b\u95f4\u7684\u968f\u673a\u6574\u6570\u3002<\/p>\n<p><strong>Python\u4e2d\u751f\u6210\u968f\u673a\u6570\u7684\u5e38\u7528\u65b9\u6cd5\u6709\u54ea\u4e9b\uff1f<\/strong><br \/>\u6709\u51e0\u4e2a\u5e38\u7528\u7684\u65b9\u6cd5\u53ef\u4ee5\u751f\u6210\u968f\u673a\u6570\u3002\u4f7f\u7528<code>random.random()<\/code>\u751f\u62100\u52301\u4e4b\u95f4\u7684\u6d6e\u70b9\u6570\uff0c<code>random.randint(a, b)<\/code>\u7528\u4e8e\u751f\u6210\u6307\u5b9a\u8303\u56f4\u5185\u7684\u6574\u6570\uff0c\u8fd8\u6709<code>random.choice(sequence)<\/code>\u53ef\u4ee5\u4ece\u7ed9\u5b9a\u7684\u5e8f\u5217\u4e2d\u968f\u673a\u9009\u62e9\u4e00\u4e2a\u5143\u7d20\u3002\u6b64\u5916\uff0c<code>random.uniform(a, b)<\/code>\u53ef\u4ee5\u751f\u6210\u6307\u5b9a\u8303\u56f4\u5185\u7684\u968f\u673a\u6d6e\u70b9\u6570\u3002<\/p>\n<p><strong>\u5982\u4f55\u786e\u4fdd\u5728Python\u4e2d\u751f\u6210\u7684\u968f\u673a\u6570\u662f\u4e0d\u53ef\u9884\u6d4b\u7684\uff1f<\/strong><br \/>\u4e3a\u4e86\u786e\u4fdd\u751f\u6210\u7684\u968f\u673a\u6570\u4e0d\u53ef\u9884\u6d4b\uff0c\u53ef\u4ee5\u4f7f\u7528<code>random.seed()<\/code>\u51fd\u6570\u8bbe\u7f6e\u968f\u673a\u6570\u751f\u6210\u5668\u7684\u79cd\u5b50\u3002\u901a\u8fc7\u63d0\u4f9b\u4e00\u4e2a\u7279\u5b9a\u7684\u79cd\u5b50\u503c\uff0c\u53ef\u4ee5\u786e\u4fdd\u6bcf\u6b21\u8fd0\u884c\u7a0b\u5e8f\u65f6\u751f\u6210\u7684\u968f\u673a\u6570\u5e8f\u5217\u662f\u76f8\u540c\u7684\u3002\u5982\u679c\u5e0c\u671b\u6bcf\u6b21\u8fd0\u884c\u90fd\u5f97\u5230\u4e0d\u540c\u7684\u968f\u673a\u6570\uff0c\u53ef\u4ee5\u4e0d\u8bbe\u7f6e\u79cd\u5b50\u503c\uff0c\u6216\u8005\u4f7f\u7528\u7cfb\u7edf\u65f6\u95f4\u4f5c\u4e3a\u79cd\u5b50\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Python\u5982\u4f55\u5efa\u7acb\u968f\u673a\u6570\uff1f\u4f7f\u7528random\u6a21\u5757\u3001\u4f7f\u7528numpy\u5e93\u3001\u4f7f\u7528secrets\u6a21\u5757\u3001\u4f7f\u7528os\u6a21\u5757\u3002\u5176\u4e2d [&hellip;]","protected":false},"author":3,"featured_media":1177641,"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\/1177630"}],"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=1177630"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1177630\/revisions"}],"predecessor-version":[{"id":1177642,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1177630\/revisions\/1177642"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1177641"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1177630"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1177630"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1177630"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}