{"id":585,"date":"2025-10-23T15:26:26","date_gmt":"2025-10-23T07:26:26","guid":{"rendered":"http:\/\/www.pyteam.cn\/?p=585"},"modified":"2025-10-23T15:26:26","modified_gmt":"2025-10-23T07:26:26","slug":"python3-%e6%95%b0%e5%ad%97number","status":"publish","type":"post","link":"http:\/\/www.pyteam.cn\/index.php\/2025\/10\/23\/python3-%e6%95%b0%e5%ad%97number\/","title":{"rendered":"Python3 \u6570\u5b57(Number)"},"content":{"rendered":"\n<p>Python \u6570\u5b57\u6570\u636e\u7c7b\u578b\u7528\u4e8e\u5b58\u50a8\u6570\u503c\u3002<\/p>\n\n\n\n<p>\u6570\u636e\u7c7b\u578b\u662f\u4e0d\u5141\u8bb8\u6539\u53d8\u7684\uff0c\u8fd9\u5c31\u610f\u5473\u7740\u5982\u679c\u6539\u53d8\u6570\u5b57\u6570\u636e\u7c7b\u578b\u7684\u503c\uff0c\u5c06\u91cd\u65b0\u5206\u914d\u5185\u5b58\u7a7a\u95f4\u3002<\/p>\n\n\n\n<p>\u4ee5\u4e0b\u5b9e\u4f8b\u5728\u53d8\u91cf\u8d4b\u503c\u65f6 Number \u5bf9\u8c61\u5c06\u88ab\u521b\u5efa\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">var1 = 1\nvar2 = 10<\/pre>\n\n\n\n<p>\u60a8\u4e5f\u53ef\u4ee5\u4f7f\u7528del\u8bed\u53e5\u5220\u9664\u4e00\u4e9b\u6570\u5b57\u5bf9\u8c61\u7684\u5f15\u7528\u3002<\/p>\n\n\n\n<p>del\u8bed\u53e5\u7684\u8bed\u6cd5\u662f\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">del var1[,var2[,var3[....,varN]]]<\/pre>\n\n\n\n<p>\u60a8\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528del\u8bed\u53e5\u5220\u9664\u5355\u4e2a\u6216\u591a\u4e2a\u5bf9\u8c61\u7684\u5f15\u7528\uff0c\u4f8b\u5982\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">del var\ndel var_a, var_b<\/pre>\n\n\n\n<p>Python \u652f\u6301\u4e09\u79cd\u4e0d\u540c\u7684\u6570\u503c\u7c7b\u578b\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u6574\u578b(int)<\/strong>\u00a0&#8211; \u901a\u5e38\u88ab\u79f0\u4e3a\u662f\u6574\u578b\u6216\u6574\u6570\uff0c\u662f\u6b63\u6216\u8d1f\u6574\u6570\uff0c\u4e0d\u5e26\u5c0f\u6570\u70b9\u3002Python3 \u6574\u578b\u662f\u6ca1\u6709\u9650\u5236\u5927\u5c0f\u7684\uff0c\u53ef\u4ee5\u5f53\u4f5c Long \u7c7b\u578b\u4f7f\u7528\uff0c\u6240\u4ee5 Python3 \u6ca1\u6709 Python2 \u7684 Long \u7c7b\u578b\u3002\u5e03\u5c14(bool)\u662f\u6574\u578b\u7684\u5b50\u7c7b\u578b\u3002<\/li>\n\n\n\n<li><strong>\u6d6e\u70b9\u578b(float)<\/strong>\u00a0&#8211; \u6d6e\u70b9\u578b\u7531\u6574\u6570\u90e8\u5206\u4e0e\u5c0f\u6570\u90e8\u5206\u7ec4\u6210\uff0c\u6d6e\u70b9\u578b\u4e5f\u53ef\u4ee5\u4f7f\u7528\u79d1\u5b66\u8ba1\u6570\u6cd5\u8868\u793a\uff082.5e2 = 2.5 x 10<sup>2<\/sup>\u00a0= 250\uff09<\/li>\n\n\n\n<li><strong>\u590d\u6570( (complex))<\/strong>\u00a0&#8211; \u590d\u6570\u7531\u5b9e\u6570\u90e8\u5206\u548c\u865a\u6570\u90e8\u5206\u6784\u6210\uff0c\u53ef\u4ee5\u7528a + bj,\u6216\u8005complex(a,b)\u8868\u793a\uff0c \u590d\u6570\u7684\u5b9e\u90e8a\u548c\u865a\u90e8b\u90fd\u662f\u6d6e\u70b9\u578b\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u5341\u516d\u8fdb\u5236\u548c\u516b\u8fdb\u5236\u6765\u4ee3\u8868\u6574\u6570\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&gt;&gt;&gt; number = 0xA0F # \u5341\u516d\u8fdb\u5236\n&gt;&gt;&gt; number\n2575\n\n&gt;&gt;&gt; number=0o37 # \u516b\u8fdb\u5236\n&gt;&gt;&gt; number\n31<\/pre>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>int<\/th><th>float<\/th><th>complex<\/th><\/tr><tr><td>10<\/td><td>0.0<\/td><td>3.14j<\/td><\/tr><tr><td>100<\/td><td>15.20<\/td><td>45.j<\/td><\/tr><tr><td>-786<\/td><td>-21.9<\/td><td>9.322e-36j<\/td><\/tr><tr><td>080<\/td><td>32.3e+18<\/td><td>.876j<\/td><\/tr><tr><td>-0490<\/td><td>-90.<\/td><td>-.6545+0J<\/td><\/tr><tr><td>-0x260<\/td><td>-32.54e100<\/td><td>3e+26J<\/td><\/tr><tr><td>0x69<\/td><td>70.2E-12<\/td><td>4.53e-7j<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Python\u652f\u6301\u590d\u6570\uff0c\u590d\u6570\u7531\u5b9e\u6570\u90e8\u5206\u548c\u865a\u6570\u90e8\u5206\u6784\u6210\uff0c\u53ef\u4ee5\u7528a + bj,\u6216\u8005complex(a,b)\u8868\u793a\uff0c \u590d\u6570\u7684\u5b9e\u90e8a\u548c\u865a\u90e8b\u90fd\u662f\u6d6e\u70b9\u578b\u3002<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Python \u6570\u5b57\u7c7b\u578b\u8f6c\u6362<\/h2>\n\n\n\n<p>\u6709\u65f6\u5019\uff0c\u6211\u4eec\u9700\u8981\u5bf9\u6570\u636e\u5185\u7f6e\u7684\u7c7b\u578b\u8fdb\u884c\u8f6c\u6362\uff0c\u6570\u636e\u7c7b\u578b\u7684\u8f6c\u6362\uff0c\u4f60\u53ea\u9700\u8981\u5c06\u6570\u636e\u7c7b\u578b\u4f5c\u4e3a\u51fd\u6570\u540d\u5373\u53ef\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>int(x)<\/strong>\u00a0\u5c06x\u8f6c\u6362\u4e3a\u4e00\u4e2a\u6574\u6570\u3002<\/li>\n\n\n\n<li><strong>float(x)<\/strong>\u00a0\u5c06x\u8f6c\u6362\u5230\u4e00\u4e2a\u6d6e\u70b9\u6570\u3002<\/li>\n\n\n\n<li><strong>complex(x)<\/strong>\u00a0\u5c06x\u8f6c\u6362\u5230\u4e00\u4e2a\u590d\u6570\uff0c\u5b9e\u6570\u90e8\u5206\u4e3a x\uff0c\u865a\u6570\u90e8\u5206\u4e3a 0\u3002<\/li>\n\n\n\n<li><strong>complex(x, y)<\/strong>\u00a0\u5c06 x \u548c y \u8f6c\u6362\u5230\u4e00\u4e2a\u590d\u6570\uff0c\u5b9e\u6570\u90e8\u5206\u4e3a x\uff0c\u865a\u6570\u90e8\u5206\u4e3a y\u3002x \u548c y \u662f\u6570\u5b57\u8868\u8fbe\u5f0f\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u4ee5\u4e0b\u5b9e\u4f8b\u5c06\u6d6e\u70b9\u6570\u53d8\u91cf a \u8f6c\u6362\u4e3a\u6574\u6570\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&gt;&gt;&gt; a = 1.0\n&gt;&gt;&gt; int(a)\n1<\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Python \u6570\u5b57\u8fd0\u7b97<\/h2>\n\n\n\n<p>Python \u89e3\u91ca\u5668\u53ef\u4ee5\u4f5c\u4e3a\u4e00\u4e2a\u7b80\u5355\u7684\u8ba1\u7b97\u5668\uff0c\u60a8\u53ef\u4ee5\u5728\u89e3\u91ca\u5668\u91cc\u8f93\u5165\u4e00\u4e2a\u8868\u8fbe\u5f0f\uff0c\u5b83\u5c06\u8f93\u51fa\u8868\u8fbe\u5f0f\u7684\u503c\u3002<\/p>\n\n\n\n<p>\u8868\u8fbe\u5f0f\u7684\u8bed\u6cd5\u5f88\u76f4\u767d\uff1a&nbsp;<strong>+<\/strong>,&nbsp;<strong>&#8211;<\/strong>,&nbsp;<strong>*<\/strong>&nbsp;\u548c&nbsp;<strong>\/<\/strong>, \u548c\u5176\u5b83\u8bed\u8a00\uff08\u5982Pascal\u6216C\uff09\u91cc\u4e00\u6837\u3002\u4f8b\u5982\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&gt;&gt;&gt; 2 + 2\n4\n&gt;&gt;&gt; 50 - 5*6\n20\n&gt;&gt;&gt; (50 - 5*6) \/ 4\n5.0\n&gt;&gt;&gt; 8 \/ 5  # \u603b\u662f\u8fd4\u56de\u4e00\u4e2a\u6d6e\u70b9\u6570\n1.6<\/pre>\n\n\n\n<p><strong>\u6ce8\u610f\uff1a<\/strong>\u5728\u4e0d\u540c\u7684\u673a\u5668\u4e0a\u6d6e\u70b9\u8fd0\u7b97\u7684\u7ed3\u679c\u53ef\u80fd\u4f1a\u4e0d\u4e00\u6837\u3002<\/p>\n\n\n\n<p>\u5728\u6574\u6570\u9664\u6cd5\u4e2d\uff0c\u9664\u6cd5&nbsp;<strong>\/<\/strong>&nbsp;\u603b\u662f\u8fd4\u56de\u4e00\u4e2a\u6d6e\u70b9\u6570\uff0c\u5982\u679c\u53ea\u60f3\u5f97\u5230\u6574\u6570\u7684\u7ed3\u679c\uff0c\u4e22\u5f03\u53ef\u80fd\u7684\u5206\u6570\u90e8\u5206\uff0c\u53ef\u4ee5\u4f7f\u7528\u8fd0\u7b97\u7b26&nbsp;<strong>\/\/<\/strong>&nbsp;\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&gt;&gt;&gt; 17 \/ 3  # \u6574\u6570\u9664\u6cd5\u8fd4\u56de\u6d6e\u70b9\u578b\n5.666666666666667\n&gt;&gt;&gt;\n&gt;&gt;&gt; 17 \/\/ 3  # \u6574\u6570\u9664\u6cd5\u8fd4\u56de\u5411\u4e0b\u53d6\u6574\u540e\u7684\u7ed3\u679c\n5\n&gt;&gt;&gt; 17 % 3  # \uff05\u64cd\u4f5c\u7b26\u8fd4\u56de\u9664\u6cd5\u7684\u4f59\u6570\n2\n&gt;&gt;&gt; 5 * 3 + 2 \n17<\/pre>\n\n\n\n<p><strong>\u6ce8\u610f\uff1a<\/strong><strong>\/\/<\/strong>&nbsp;\u5f97\u5230\u7684\u5e76\u4e0d\u4e00\u5b9a\u662f\u6574\u6570\u7c7b\u578b\u7684\u6570\uff0c\u5b83\u4e0e\u5206\u6bcd\u5206\u5b50\u7684\u6570\u636e\u7c7b\u578b\u6709\u5173\u7cfb\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&gt;&gt;&gt; 7\/\/2\n3\n&gt;&gt;&gt; 7.0\/\/2\n3.0\n&gt;&gt;&gt; 7\/\/2.0\n3.0\n&gt;&gt;&gt; <\/pre>\n\n\n\n<p>\u7b49\u53f7&nbsp;<strong>=<\/strong>&nbsp;\u7528\u4e8e\u7ed9\u53d8\u91cf\u8d4b\u503c\u3002\u8d4b\u503c\u4e4b\u540e\uff0c\u9664\u4e86\u4e0b\u4e00\u4e2a\u63d0\u793a\u7b26\uff0c\u89e3\u91ca\u5668\u4e0d\u4f1a\u663e\u793a\u4efb\u4f55\u7ed3\u679c\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&gt;&gt;&gt; width = 20\n&gt;&gt;&gt; height = 5*9\n&gt;&gt;&gt; width * height\n900<\/pre>\n\n\n\n<p>Python \u53ef\u4ee5\u4f7f\u7528&nbsp;<strong>**<\/strong>&nbsp;\u64cd\u4f5c\u6765\u8fdb\u884c\u5e42\u8fd0\u7b97\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&gt;&gt;&gt; 5 ** 2  # 5 \u7684\u5e73\u65b9\n25\n&gt;&gt;&gt; 2 ** 7  # 2\u76847\u6b21\u65b9\n128<\/pre>\n\n\n\n<p>\u53d8\u91cf\u5728\u4f7f\u7528\u524d\u5fc5\u987b\u5148&#8221;\u5b9a\u4e49&#8221;\uff08\u5373\u8d4b\u4e88\u53d8\u91cf\u4e00\u4e2a\u503c\uff09\uff0c\u5426\u5219\u4f1a\u51fa\u73b0\u9519\u8bef\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&gt;&gt;&gt; n   # \u5c1d\u8bd5\u8bbf\u95ee\u4e00\u4e2a\u672a\u5b9a\u4e49\u7684\u53d8\u91cf\nTraceback (most recent call last):\n  File \"&lt;stdin&gt;\", line 1, in &lt;module&gt;\nNameError: name 'n' is not defined<\/pre>\n\n\n\n<p>\u4e0d\u540c\u7c7b\u578b\u7684\u6570\u6df7\u5408\u8fd0\u7b97\u65f6\u4f1a\u5c06\u6574\u6570\u8f6c\u6362\u4e3a\u6d6e\u70b9\u6570\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&gt;&gt;&gt; 3 * 3.75 \/ 1.5\n7.5\n&gt;&gt;&gt; 7.0 \/ 2\n3.5<\/pre>\n\n\n\n<p>\u5728\u4ea4\u4e92\u6a21\u5f0f\u4e2d\uff0c\u6700\u540e\u88ab\u8f93\u51fa\u7684\u8868\u8fbe\u5f0f\u7ed3\u679c\u88ab\u8d4b\u503c\u7ed9\u53d8\u91cf&nbsp;<strong>_&nbsp;<\/strong>\u3002\u4f8b\u5982\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&gt;&gt;&gt; tax = 12.5 \/ 100\n&gt;&gt;&gt; price = 100.50\n&gt;&gt;&gt; price * tax\n12.5625\n&gt;&gt;&gt; price + _\n113.0625\n&gt;&gt;&gt; round(_, 2)\n113.06<\/pre>\n\n\n\n<p>\u6b64\u5904\uff0c&nbsp;<strong>_&nbsp;<\/strong>\u53d8\u91cf\u5e94\u88ab\u7528\u6237\u89c6\u4e3a\u53ea\u8bfb\u53d8\u91cf\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u6570\u5b66\u51fd\u6570<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>\u51fd\u6570<\/th><th>\u8fd4\u56de\u503c ( \u63cf\u8ff0 )<\/th><\/tr><tr><td><a target=\"_blank\" href=\"https:\/\/www.runoob.com\/python3\/python3-func-number-abs.html\" rel=\"noreferrer noopener\">abs(x)<\/a><\/td><td>\u8fd4\u56de\u6570\u5b57\u7684\u7edd\u5bf9\u503c\uff0c\u5982abs(-10) \u8fd4\u56de 10<\/td><\/tr><tr><td><a target=\"_blank\" href=\"https:\/\/www.runoob.com\/python3\/python3-func-number-ceil.html\" rel=\"noreferrer noopener\">ceil(x)<\/a><\/td><td>\u8fd4\u56de\u6570\u5b57\u7684\u4e0a\u5165\u6574\u6570\uff0c\u5982math.ceil(4.1) \u8fd4\u56de 5<\/td><\/tr><tr><td>cmp(x, y)<\/td><td>\u5982\u679c x &lt; y \u8fd4\u56de -1, \u5982\u679c x == y \u8fd4\u56de 0, \u5982\u679c x &gt; y \u8fd4\u56de 1\u3002&nbsp;<strong>Python 3 \u5df2\u5e9f\u5f03\uff0c\u4f7f\u7528 (x&gt;y)-(x&lt;y) \u66ff\u6362<\/strong>\u3002<\/td><\/tr><tr><td><a target=\"_blank\" href=\"https:\/\/www.runoob.com\/python3\/python3-func-number-exp.html\" rel=\"noreferrer noopener\">exp(x)<\/a><\/td><td>\u8fd4\u56dee\u7684x\u6b21\u5e42(e<sup>x<\/sup>),\u5982math.exp(1) \u8fd4\u56de2.718281828459045<\/td><\/tr><tr><td><a target=\"_blank\" href=\"https:\/\/www.runoob.com\/python3\/python3-func-number-fabs.html\" rel=\"noreferrer noopener\">fabs(x)<\/a><\/td><td>\u4ee5\u6d6e\u70b9\u6570\u5f62\u5f0f\u8fd4\u56de\u6570\u5b57\u7684\u7edd\u5bf9\u503c\uff0c\u5982math.fabs(-10) \u8fd4\u56de10.0<\/td><\/tr><tr><td><a target=\"_blank\" href=\"https:\/\/www.runoob.com\/python3\/python3-func-number-floor.html\" rel=\"noreferrer noopener\">floor(x)<\/a><\/td><td>\u8fd4\u56de\u6570\u5b57\u7684\u4e0b\u820d\u6574\u6570\uff0c\u5982math.floor(4.9)\u8fd4\u56de 4<\/td><\/tr><tr><td><a target=\"_blank\" href=\"https:\/\/www.runoob.com\/python3\/python3-func-number-log.html\" rel=\"noreferrer noopener\">log(x)<\/a><\/td><td>\u5982math.log(math.e)\u8fd4\u56de1.0,math.log(100,10)\u8fd4\u56de2.0<\/td><\/tr><tr><td><a target=\"_blank\" href=\"https:\/\/www.runoob.com\/python3\/python3-func-number-log10.html\" rel=\"noreferrer noopener\">log10(x)<\/a><\/td><td>\u8fd4\u56de\u4ee510\u4e3a\u57fa\u6570\u7684x\u7684\u5bf9\u6570\uff0c\u5982math.log10(100)\u8fd4\u56de 2.0<\/td><\/tr><tr><td><a target=\"_blank\" href=\"https:\/\/www.runoob.com\/python3\/python3-func-number-max.html\" rel=\"noreferrer noopener\">max(x1, x2,&#8230;)<\/a><\/td><td>\u8fd4\u56de\u7ed9\u5b9a\u53c2\u6570\u7684\u6700\u5927\u503c\uff0c\u53c2\u6570\u53ef\u4ee5\u4e3a\u5e8f\u5217\u3002<\/td><\/tr><tr><td><a target=\"_blank\" href=\"https:\/\/www.runoob.com\/python3\/python3-func-number-min.html\" rel=\"noreferrer noopener\">min(x1, x2,&#8230;)<\/a><\/td><td>\u8fd4\u56de\u7ed9\u5b9a\u53c2\u6570\u7684\u6700\u5c0f\u503c\uff0c\u53c2\u6570\u53ef\u4ee5\u4e3a\u5e8f\u5217\u3002<\/td><\/tr><tr><td><a target=\"_blank\" href=\"https:\/\/www.runoob.com\/python3\/python3-func-number-modf.html\" rel=\"noreferrer noopener\">modf(x)<\/a><\/td><td>\u8fd4\u56dex\u7684\u6574\u6570\u90e8\u5206\u4e0e\u5c0f\u6570\u90e8\u5206\uff0c\u4e24\u90e8\u5206\u7684\u6570\u503c\u7b26\u53f7\u4e0ex\u76f8\u540c\uff0c\u6574\u6570\u90e8\u5206\u4ee5\u6d6e\u70b9\u578b\u8868\u793a\u3002<\/td><\/tr><tr><td><a target=\"_blank\" href=\"https:\/\/www.runoob.com\/python3\/python3-func-number-pow.html\" rel=\"noreferrer noopener\">pow(x, y)<\/a><\/td><td>x**y \u8fd0\u7b97\u540e\u7684\u503c\u3002<\/td><\/tr><tr><td><a target=\"_blank\" href=\"https:\/\/www.runoob.com\/python3\/python3-func-number-round.html\" rel=\"noreferrer noopener\">round(x [,n])<\/a><\/td><td>\u8fd4\u56de\u6d6e\u70b9\u6570 x \u7684\u56db\u820d\u4e94\u5165\u503c\uff0c\u5982\u7ed9\u51fa n \u503c\uff0c\u5219\u4ee3\u8868\u820d\u5165\u5230\u5c0f\u6570\u70b9\u540e\u7684\u4f4d\u6570\u3002<strong>\u5176\u5b9e\u51c6\u786e\u7684\u8bf4\u662f\u4fdd\u7559\u503c\u5c06\u4fdd\u7559\u5230\u79bb\u4e0a\u4e00\u4f4d\u66f4\u8fd1\u7684\u4e00\u7aef\u3002<\/strong><\/td><\/tr><tr><td><a target=\"_blank\" href=\"https:\/\/www.runoob.com\/python3\/python3-func-number-sqrt.html\" rel=\"noreferrer noopener\">sqrt(x)<\/a><\/td><td>\u8fd4\u56de\u6570\u5b57x\u7684\u5e73\u65b9\u6839\u3002<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u968f\u673a\u6570\u51fd\u6570<\/h2>\n\n\n\n<p>\u968f\u673a\u6570\u53ef\u4ee5\u7528\u4e8e\u6570\u5b66\uff0c\u6e38\u620f\uff0c\u5b89\u5168\u7b49\u9886\u57df\u4e2d\uff0c\u8fd8\u7ecf\u5e38\u88ab\u5d4c\u5165\u5230\u7b97\u6cd5\u4e2d\uff0c\u7528\u4ee5\u63d0\u9ad8\u7b97\u6cd5\u6548\u7387\uff0c\u5e76\u63d0\u9ad8\u7a0b\u5e8f\u7684\u5b89\u5168\u6027\u3002<\/p>\n\n\n\n<p>Python\u5305\u542b\u4ee5\u4e0b\u5e38\u7528\u968f\u673a\u6570\u51fd\u6570\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>\u51fd\u6570<\/th><th>\u63cf\u8ff0<\/th><\/tr><tr><td><a target=\"_blank\" href=\"https:\/\/www.runoob.com\/python3\/python3-func-number-choice.html\" rel=\"noreferrer noopener\">choice(seq)<\/a><\/td><td>\u4ece\u5e8f\u5217\u7684\u5143\u7d20\u4e2d\u968f\u673a\u6311\u9009\u4e00\u4e2a\u5143\u7d20\uff0c\u6bd4\u5982random.choice(range(10))\uff0c\u4ece0\u52309\u4e2d\u968f\u673a\u6311\u9009\u4e00\u4e2a\u6574\u6570\u3002<\/td><\/tr><tr><td><a target=\"_blank\" href=\"https:\/\/www.runoob.com\/python3\/python3-func-number-randrange.html\" rel=\"noreferrer noopener\">randrange ([start,] stop [,step])<\/a><\/td><td>\u4ece\u6307\u5b9a\u8303\u56f4\u5185\uff0c\u6309\u6307\u5b9a\u57fa\u6570\u9012\u589e\u7684\u96c6\u5408\u4e2d\u83b7\u53d6\u4e00\u4e2a\u968f\u673a\u6570\uff0c\u57fa\u6570\u9ed8\u8ba4\u503c\u4e3a 1<\/td><\/tr><tr><td><a target=\"_blank\" href=\"https:\/\/www.runoob.com\/python3\/python3-func-number-random.html\" rel=\"noreferrer noopener\">random()<\/a><\/td><td>\u968f\u673a\u751f\u6210\u4e0b\u4e00\u4e2a\u5b9e\u6570\uff0c\u5b83\u5728[0,1)\u8303\u56f4\u5185\u3002<\/td><\/tr><tr><td><a target=\"_blank\" href=\"https:\/\/www.runoob.com\/python3\/python3-func-number-seed.html\" rel=\"noreferrer noopener\">seed([x])<\/a><\/td><td>\u6539\u53d8\u968f\u673a\u6570\u751f\u6210\u5668\u7684\u79cd\u5b50seed\u3002\u5982\u679c\u4f60\u4e0d\u4e86\u89e3\u5176\u539f\u7406\uff0c\u4f60\u4e0d\u5fc5\u7279\u522b\u53bb\u8bbe\u5b9aseed\uff0cPython\u4f1a\u5e2e\u4f60\u9009\u62e9seed\u3002<\/td><\/tr><tr><td><a target=\"_blank\" href=\"https:\/\/www.runoob.com\/python3\/python3-func-number-shuffle.html\" rel=\"noreferrer noopener\">shuffle(lst)<\/a><\/td><td>\u5c06\u5e8f\u5217\u7684\u6240\u6709\u5143\u7d20\u968f\u673a\u6392\u5e8f<\/td><\/tr><tr><td><a target=\"_blank\" href=\"https:\/\/www.runoob.com\/python3\/python3-func-number-uniform.html\" rel=\"noreferrer noopener\">uniform(x, y)<\/a><\/td><td>\u968f\u673a\u751f\u6210\u4e0b\u4e00\u4e2a\u5b9e\u6570\uff0c\u5b83\u5728[x,y]\u8303\u56f4\u5185\u3002<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e09\u89d2\u51fd\u6570<\/h2>\n\n\n\n<p>Python\u5305\u62ec\u4ee5\u4e0b\u4e09\u89d2\u51fd\u6570\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>\u51fd\u6570<\/th><th>\u63cf\u8ff0<\/th><\/tr><tr><td><a target=\"_blank\" href=\"https:\/\/www.runoob.com\/python3\/python3-func-number-acos.html\" rel=\"noreferrer noopener\">acos(x)<\/a><\/td><td>\u8fd4\u56dex\u7684\u53cd\u4f59\u5f26\u5f27\u5ea6\u503c\u3002<\/td><\/tr><tr><td><a target=\"_blank\" href=\"https:\/\/www.runoob.com\/python3\/python3-func-number-asin.html\" rel=\"noreferrer noopener\">asin(x)<\/a><\/td><td>\u8fd4\u56dex\u7684\u53cd\u6b63\u5f26\u5f27\u5ea6\u503c\u3002<\/td><\/tr><tr><td><a target=\"_blank\" href=\"https:\/\/www.runoob.com\/python3\/python3-func-number-atan.html\" rel=\"noreferrer noopener\">atan(x)<\/a><\/td><td>\u8fd4\u56dex\u7684\u53cd\u6b63\u5207\u5f27\u5ea6\u503c\u3002<\/td><\/tr><tr><td><a target=\"_blank\" href=\"https:\/\/www.runoob.com\/python3\/python3-func-number-atan2.html\" rel=\"noreferrer noopener\">atan2(y, x)<\/a><\/td><td>\u8fd4\u56de\u7ed9\u5b9a\u7684 X \u53ca Y \u5750\u6807\u503c\u7684\u53cd\u6b63\u5207\u503c\u3002<\/td><\/tr><tr><td><a target=\"_blank\" href=\"https:\/\/www.runoob.com\/python3\/python3-func-number-cos.html\" rel=\"noreferrer noopener\">cos(x)<\/a><\/td><td>\u8fd4\u56dex\u7684\u5f27\u5ea6\u7684\u4f59\u5f26\u503c\u3002<\/td><\/tr><tr><td><a target=\"_blank\" href=\"https:\/\/www.runoob.com\/python3\/python3-func-number-hypot.html\" rel=\"noreferrer noopener\">hypot(x, y)<\/a><\/td><td>\u8fd4\u56de\u6b27\u51e0\u91cc\u5fb7\u8303\u6570 sqrt(x*x + y*y)\u3002<\/td><\/tr><tr><td><a target=\"_blank\" href=\"https:\/\/www.runoob.com\/python3\/python3-func-number-sin.html\" rel=\"noreferrer noopener\">sin(x)<\/a><\/td><td>\u8fd4\u56de\u7684x\u5f27\u5ea6\u7684\u6b63\u5f26\u503c\u3002<\/td><\/tr><tr><td><a target=\"_blank\" href=\"https:\/\/www.runoob.com\/python3\/python3-func-number-tan.html\" rel=\"noreferrer noopener\">tan(x)<\/a><\/td><td>\u8fd4\u56dex\u5f27\u5ea6\u7684\u6b63\u5207\u503c\u3002<\/td><\/tr><tr><td><a target=\"_blank\" href=\"https:\/\/www.runoob.com\/python3\/python3-func-number-degrees.html\" rel=\"noreferrer noopener\">degrees(x)<\/a><\/td><td>\u5c06\u5f27\u5ea6\u8f6c\u6362\u4e3a\u89d2\u5ea6,\u5982degrees(math.pi\/2) \uff0c \u8fd4\u56de90.0<\/td><\/tr><tr><td><a target=\"_blank\" href=\"https:\/\/www.runoob.com\/python3\/python3-func-number-radians.html\" rel=\"noreferrer noopener\">radians(x)<\/a><\/td><td>\u5c06\u89d2\u5ea6\u8f6c\u6362\u4e3a\u5f27\u5ea6<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u6570\u5b66\u5e38\u91cf<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>\u5e38\u91cf<\/th><th>\u63cf\u8ff0<\/th><\/tr><tr><td>pi<\/td><td>\u6570\u5b66\u5e38\u91cf pi\uff08\u5706\u5468\u7387\uff0c\u4e00\u822c\u4ee5\u03c0\u6765\u8868\u793a\uff09<\/td><\/tr><tr><td>e<\/td><td>\u6570\u5b66\u5e38\u91cf e\uff0ce\u5373\u81ea\u7136\u5e38\u6570\uff08\u81ea\u7136\u5e38\u6570\uff09\u3002<\/td><\/tr><\/tbody><\/table><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Python \u6570\u5b57\u6570\u636e\u7c7b\u578b\u7528\u4e8e\u5b58\u50a8\u6570\u503c\u3002 \u6570\u636e\u7c7b\u578b\u662f\u4e0d\u5141\u8bb8\u6539\u53d8\u7684\uff0c\u8fd9&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":478,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-585","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-1"],"views":645,"_links":{"self":[{"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/posts\/585","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/comments?post=585"}],"version-history":[{"count":1,"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/posts\/585\/revisions"}],"predecessor-version":[{"id":586,"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/posts\/585\/revisions\/586"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/media\/478"}],"wp:attachment":[{"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/media?parent=585"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/categories?post=585"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/tags?post=585"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}