{"id":1141960,"date":"2025-01-08T22:35:36","date_gmt":"2025-01-08T14:35:36","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1141960.html"},"modified":"2025-01-08T22:35:39","modified_gmt":"2025-01-08T14:35:39","slug":"python%e6%b5%ae%e7%82%b9%e5%9e%8b%e8%bd%ac%e5%8c%96%e4%b8%ba%e6%95%b4%e5%9e%8b%e5%a6%82%e4%bd%95%e5%9b%9b%e8%88%8d%e4%ba%94%e5%85%a5","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1141960.html","title":{"rendered":"python\u6d6e\u70b9\u578b\u8f6c\u5316\u4e3a\u6574\u578b\u5982\u4f55\u56db\u820d\u4e94\u5165"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25104535\/c95afab6-0513-4768-bb13-c4ae4d29ef62.webp\" alt=\"python\u6d6e\u70b9\u578b\u8f6c\u5316\u4e3a\u6574\u578b\u5982\u4f55\u56db\u820d\u4e94\u5165\" \/><\/p>\n<p><p> <strong>Python \u6d6e\u70b9\u578b\u8f6c\u5316\u4e3a\u6574\u578b\u5982\u4f55\u56db\u820d\u4e94\u5165\uff0c\u53ef\u4ee5\u4f7f\u7528 <code>round()<\/code> \u51fd\u6570\u3001<code>int()<\/code> \u51fd\u6570\u4ee5\u53ca <code>math.floor()<\/code> \u548c <code>math.ceil()<\/code> \u51fd\u6570\u7b49\u65b9\u6cd5\u3002<\/strong> \u5176\u4e2d\uff0c\u6700\u5e38\u7528\u7684\u5c31\u662f <code>round()<\/code> \u51fd\u6570\uff0c\u56e0\u4e3a\u5b83\u80fd\u591f\u76f4\u63a5\u5bf9\u6d6e\u70b9\u6570\u8fdb\u884c\u56db\u820d\u4e94\u5165\u64cd\u4f5c\u5e76\u8fd4\u56de\u6574\u578b\u7ed3\u679c\u3002\u4e0b\u9762\u6211\u4eec\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528\u8fd9\u4e9b\u65b9\u6cd5\uff0c\u5e76\u63a2\u8ba8\u6bcf\u79cd\u65b9\u6cd5\u7684\u4f18\u7f3a\u70b9\u548c\u9002\u7528\u573a\u666f\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u4f7f\u7528 <code>round()<\/code> \u51fd\u6570<\/h3>\n<\/p>\n<p><p><code>round()<\/code> \u51fd\u6570\u662f Python \u4e2d\u7528\u4e8e\u56db\u820d\u4e94\u5165\u6d6e\u70b9\u6570\u6700\u5e38\u7528\u7684\u65b9\u6cd5\u3002\u5b83\u7684\u8bed\u6cd5\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u8981\u4f20\u5165\u4e00\u4e2a\u6d6e\u70b9\u6570\u5373\u53ef\u3002<code>round()<\/code> \u51fd\u6570\u8fd8\u53ef\u4ee5\u63a5\u53d7\u7b2c\u4e8c\u4e2a\u53c2\u6570\uff0c\u6307\u5b9a\u8981\u4fdd\u7559\u7684\u5c0f\u6570\u4f4d\u6570\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">float_number = 3.6<\/p>\n<p>rounded_number = round(float_number)<\/p>\n<p>print(rounded_number)  # \u8f93\u51fa\uff1a4<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u8be6\u7ec6\u63cf\u8ff0<\/h4>\n<\/p>\n<p><p><strong>\u4f18\u70b9\uff1a<\/strong><\/p>\n<\/p>\n<ul>\n<li><strong>\u7b80\u5355\u6613\u7528<\/strong>\uff1a\u53ea\u9700\u4f20\u5165\u4e00\u4e2a\u6d6e\u70b9\u6570\uff0c\u8fd4\u56de\u503c\u5373\u4e3a\u56db\u820d\u4e94\u5165\u540e\u7684\u6574\u578b\u3002<\/li>\n<li><strong>\u53ef\u9009\u5c0f\u6570\u4f4d\u6570<\/strong>\uff1a\u53ef\u4ee5\u901a\u8fc7\u7b2c\u4e8c\u4e2a\u53c2\u6570\u6307\u5b9a\u4fdd\u7559\u7684\u5c0f\u6570\u4f4d\u6570\uff0c\u975e\u5e38\u7075\u6d3b\u3002<\/li>\n<\/ul>\n<p><p><strong>\u7f3a\u70b9\uff1a<\/strong><\/p>\n<\/p>\n<ul>\n<li><strong>\u56db\u820d\u4e94\u5165\u89c4\u5219<\/strong>\uff1a\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff08\u59820.5\uff09\uff0cPython \u7684 <code>round()<\/code> \u51fd\u6570\u4f1a\u4f7f\u7528\u201c\u94f6\u884c\u5bb6\u820d\u5165\u6cd5\u201d\uff0c\u5373\u56db\u820d\u516d\u5165\u4e94\u53d6\u5076\uff0c\u8fd9\u53ef\u80fd\u4e0e\u9884\u671f\u7684\u6807\u51c6\u56db\u820d\u4e94\u5165\u6709\u504f\u5dee\u3002<\/li>\n<\/ul>\n<p><h3>\u4e8c\u3001\u4f7f\u7528 <code>int()<\/code> \u51fd\u6570<\/h3>\n<\/p>\n<p><p>\u867d\u7136 <code>int()<\/code> \u51fd\u6570\u5e76\u4e0d\u63d0\u4f9b\u56db\u820d\u4e94\u5165\u529f\u80fd\uff0c\u4f46\u5b83\u53ef\u4ee5\u5c06\u6d6e\u70b9\u6570\u76f4\u63a5\u622a\u65ad\u4e3a\u6574\u578b\u3002\u5982\u679c\u4f60\u53ea\u9700\u8981\u5c06\u6d6e\u70b9\u6570\u8f6c\u6362\u4e3a\u6574\u578b\u800c\u4e0d\u9700\u8981\u56db\u820d\u4e94\u5165\uff0c\u8fd9\u79cd\u65b9\u6cd5\u975e\u5e38\u6709\u6548\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">float_number = 3.6<\/p>\n<p>int_number = int(float_number)<\/p>\n<p>print(int_number)  # \u8f93\u51fa\uff1a3<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u8be6\u7ec6\u63cf\u8ff0<\/h4>\n<\/p>\n<p><p><strong>\u4f18\u70b9\uff1a<\/strong><\/p>\n<\/p>\n<ul>\n<li><strong>\u6027\u80fd\u8f83\u9ad8<\/strong>\uff1a\u56e0\u4e3a\u53ea\u662f\u7b80\u5355\u7684\u7c7b\u578b\u8f6c\u6362\uff0c\u6267\u884c\u901f\u5ea6\u975e\u5e38\u5feb\u3002<\/li>\n<li><strong>\u7b80\u6d01<\/strong>\uff1a\u4ee3\u7801\u975e\u5e38\u7b80\u6d01\uff0c\u6613\u4e8e\u7406\u89e3\u3002<\/li>\n<\/ul>\n<p><p><strong>\u7f3a\u70b9\uff1a<\/strong><\/p>\n<\/p>\n<ul>\n<li><strong>\u4e0d\u8fdb\u884c\u56db\u820d\u4e94\u5165<\/strong>\uff1a\u4ec5\u4ec5\u662f\u622a\u65ad\u64cd\u4f5c\uff0c\u4e0d\u9002\u7528\u4e8e\u9700\u8981\u7cbe\u786e\u56db\u820d\u4e94\u5165\u7684\u573a\u666f\u3002<\/li>\n<\/ul>\n<p><h3>\u4e09\u3001\u4f7f\u7528 <code>math.floor()<\/code> \u548c <code>math.ceil()<\/code> \u51fd\u6570<\/h3>\n<\/p>\n<p><p><code>math.floor()<\/code> \u548c <code>math.ceil()<\/code> \u51fd\u6570\u5206\u522b\u7528\u4e8e\u5411\u4e0b\u548c\u5411\u4e0a\u53d6\u6574\u3002\u8fd9\u4e24\u4e2a\u51fd\u6570\u4f4d\u4e8e Python \u7684 <code>math<\/code> \u6a21\u5757\u4e2d\uff0c\u9700\u8981\u5148\u5bfc\u5165\u8be5\u6a21\u5757\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import math<\/p>\n<p>float_number = 3.6<\/p>\n<p>floor_number = math.floor(float_number)<\/p>\n<p>ceil_number = math.ceil(float_number)<\/p>\n<p>print(floor_number)  # \u8f93\u51fa\uff1a3<\/p>\n<p>print(ceil_number)   # \u8f93\u51fa\uff1a4<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u8be6\u7ec6\u63cf\u8ff0<\/h4>\n<\/p>\n<p><p><strong>\u4f18\u70b9\uff1a<\/strong><\/p>\n<\/p>\n<ul>\n<li><strong>\u63a7\u5236\u7cbe\u786e<\/strong>\uff1a\u53ef\u4ee5\u660e\u786e\u5730\u63a7\u5236\u5411\u4e0a\u6216\u5411\u4e0b\u53d6\u6574\uff0c\u975e\u5e38\u9002\u7528\u4e8e\u7279\u5b9a\u9700\u6c42\u7684\u573a\u666f\u3002<\/li>\n<li><strong>\u6613\u4e8e\u7406\u89e3<\/strong>\uff1a\u8bed\u6cd5\u7b80\u5355\uff0c\u529f\u80fd\u660e\u786e\u3002<\/li>\n<\/ul>\n<p><p><strong>\u7f3a\u70b9\uff1a<\/strong><\/p>\n<\/p>\n<ul>\n<li><strong>\u9700\u8981\u5bfc\u5165\u6a21\u5757<\/strong>\uff1a\u76f8\u6bd4 <code>round()<\/code> \u548c <code>int()<\/code> \u51fd\u6570\uff0c\u9700\u8981\u989d\u5916\u5bfc\u5165 <code>math<\/code> \u6a21\u5757\u3002<\/li>\n<li><strong>\u4e0d\u80fd\u76f4\u63a5\u56db\u820d\u4e94\u5165<\/strong>\uff1a\u9700\u8981\u6839\u636e\u5177\u4f53\u9700\u6c42\u9009\u62e9\u5411\u4e0a\u6216\u5411\u4e0b\u53d6\u6574\uff0c\u65e0\u6cd5\u76f4\u63a5\u56db\u820d\u4e94\u5165\u3002<\/li>\n<\/ul>\n<p><h3>\u56db\u3001\u4f7f\u7528\u81ea\u5b9a\u4e49\u51fd\u6570<\/h3>\n<\/p>\n<p><p>\u5982\u679c\u4f60\u9700\u8981\u66f4\u4e3a\u7cbe\u786e\u7684\u56db\u820d\u4e94\u5165\u89c4\u5219\uff0c\u53ef\u4ee5\u81ea\u5b9a\u4e49\u4e00\u4e2a\u51fd\u6570\u6765\u5b9e\u73b0\u3002\u4f8b\u5982\uff0c\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u81ea\u5b9a\u4e49\u56db\u820d\u4e94\u5165\u51fd\u6570\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def custom_round(number):<\/p>\n<p>    if number - int(number) &gt;= 0.5:<\/p>\n<p>        return int(number) + 1<\/p>\n<p>    else:<\/p>\n<p>        return int(number)<\/p>\n<p>float_number = 3.6<\/p>\n<p>rounded_number = custom_round(float_number)<\/p>\n<p>print(rounded_number)  # \u8f93\u51fa\uff1a4<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u8be6\u7ec6\u63cf\u8ff0<\/h4>\n<\/p>\n<p><p><strong>\u4f18\u70b9\uff1a<\/strong><\/p>\n<\/p>\n<ul>\n<li><strong>\u7075\u6d3b\u6027\u9ad8<\/strong>\uff1a\u53ef\u4ee5\u6839\u636e\u5177\u4f53\u9700\u6c42\u5b9a\u4e49\u56db\u820d\u4e94\u5165\u89c4\u5219\u3002<\/li>\n<li><strong>\u53ef\u63a7\u6027\u5f3a<\/strong>\uff1a\u5b8c\u5168\u638c\u63e1\u56db\u820d\u4e94\u5165\u7684\u5b9e\u73b0\u7ec6\u8282\u3002<\/li>\n<\/ul>\n<p><p><strong>\u7f3a\u70b9\uff1a<\/strong><\/p>\n<\/p>\n<ul>\n<li><strong>\u4ee3\u7801\u590d\u6742\u5ea6\u589e\u52a0<\/strong>\uff1a\u76f8\u6bd4\u5185\u7f6e\u51fd\u6570\uff0c\u81ea\u5b9a\u4e49\u51fd\u6570\u4f1a\u589e\u52a0\u4ee3\u7801\u7684\u590d\u6742\u5ea6\u3002<\/li>\n<li><strong>\u53ef\u80fd\u7684\u6027\u80fd\u95ee\u9898<\/strong>\uff1a\u81ea\u5b9a\u4e49\u51fd\u6570\u5728\u6027\u80fd\u4e0a\u53ef\u80fd\u4e0d\u5982\u5185\u7f6e\u51fd\u6570\u9ad8\u6548\u3002<\/li>\n<\/ul>\n<p><h3>\u4e94\u3001\u7ed3\u5408\u4f7f\u7528\u591a\u79cd\u65b9\u6cd5<\/h3>\n<\/p>\n<p><p>\u5728\u5b9e\u9645\u9879\u76ee\u4e2d\uff0c\u53ef\u80fd\u9700\u8981\u7ed3\u5408\u4f7f\u7528\u591a\u79cd\u65b9\u6cd5\u6765\u6ee1\u8db3\u7279\u5b9a\u9700\u6c42\u3002\u4f8b\u5982\uff0c\u4f60\u53ef\u80fd\u9700\u8981\u5148\u4f7f\u7528 <code>math.floor()<\/code> \u6216 <code>math.ceil()<\/code> \u51fd\u6570\u8fdb\u884c\u9884\u5904\u7406\uff0c\u7136\u540e\u518d\u4f7f\u7528 <code>round()<\/code> \u51fd\u6570\u8fdb\u884c\u6700\u7ec8\u7684\u56db\u820d\u4e94\u5165\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import math<\/p>\n<p>def combined_round(number):<\/p>\n<p>    if number &lt; 0:<\/p>\n<p>        return math.ceil(number)<\/p>\n<p>    else:<\/p>\n<p>        return round(number)<\/p>\n<p>float_number = -3.6<\/p>\n<p>rounded_number = combined_round(float_number)<\/p>\n<p>print(rounded_number)  # \u8f93\u51fa\uff1a-3<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u8be6\u7ec6\u63cf\u8ff0<\/h4>\n<\/p>\n<p><p><strong>\u4f18\u70b9\uff1a<\/strong><\/p>\n<\/p>\n<ul>\n<li><strong>\u7075\u6d3b\u6027\u9ad8<\/strong>\uff1a\u53ef\u4ee5\u6839\u636e\u5177\u4f53\u9700\u6c42\u7075\u6d3b\u7ec4\u5408\u591a\u79cd\u65b9\u6cd5\u3002<\/li>\n<li><strong>\u7cbe\u786e\u63a7\u5236<\/strong>\uff1a\u80fd\u591f\u7cbe\u786e\u63a7\u5236\u6bcf\u4e00\u6b65\u7684\u53d6\u6574\u548c\u56db\u820d\u4e94\u5165\u8fc7\u7a0b\u3002<\/li>\n<\/ul>\n<p><p><strong>\u7f3a\u70b9\uff1a<\/strong><\/p>\n<\/p>\n<ul>\n<li><strong>\u4ee3\u7801\u590d\u6742\u5ea6\u589e\u52a0<\/strong>\uff1a\u9700\u8981\u7f16\u5199\u66f4\u591a\u7684\u4ee3\u7801\u6765\u5b9e\u73b0\u7ec4\u5408\u903b\u8f91\u3002<\/li>\n<li><strong>\u6f5c\u5728\u7684\u6027\u80fd\u95ee\u9898<\/strong>\uff1a\u7ec4\u5408\u591a\u79cd\u65b9\u6cd5\u53ef\u80fd\u4f1a\u5f71\u54cd\u6027\u80fd\uff0c\u7279\u522b\u662f\u5728\u5904\u7406\u5927\u91cf\u6570\u636e\u65f6\u3002<\/li>\n<\/ul>\n<p><h3>\u516d\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u8be6\u7ec6\u63a2\u8ba8\u4e86 Python \u4e2d\u5c06\u6d6e\u70b9\u578b\u8f6c\u6362\u4e3a\u6574\u578b\u5e76\u8fdb\u884c\u56db\u820d\u4e94\u5165\u7684\u591a\u79cd\u65b9\u6cd5\uff0c\u5305\u62ec <code>round()<\/code> \u51fd\u6570\u3001<code>int()<\/code> \u51fd\u6570\u3001<code>math.floor()<\/code> \u548c <code>math.ceil()<\/code> \u51fd\u6570\u4ee5\u53ca\u81ea\u5b9a\u4e49\u51fd\u6570\u3002\u6bcf\u79cd\u65b9\u6cd5\u90fd\u6709\u5176\u4f18\u7f3a\u70b9\u548c\u9002\u7528\u573a\u666f\uff0c\u5f00\u53d1\u8005\u5e94\u6839\u636e\u5177\u4f53\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><p><strong>\u6838\u5fc3\u8981\u70b9\uff1a<\/strong><\/p>\n<\/p>\n<ul>\n<li><strong><code>round()<\/code> \u51fd\u6570<\/strong>\u662f\u6700\u5e38\u7528\u7684\u56db\u820d\u4e94\u5165\u65b9\u6cd5\uff0c\u7b80\u5355\u6613\u7528\u3002<\/li>\n<li><strong><code>int()<\/code> \u51fd\u6570<\/strong>\u7528\u4e8e\u76f4\u63a5\u622a\u65ad\u6d6e\u70b9\u6570\uff0c\u4e0d\u8fdb\u884c\u56db\u820d\u4e94\u5165\u3002<\/li>\n<li><strong><code>math.floor()<\/code> \u548c <code>math.ceil()<\/code> \u51fd\u6570<\/strong>\u63d0\u4f9b\u5411\u4e0b\u548c\u5411\u4e0a\u53d6\u6574\u7684\u529f\u80fd\uff0c\u9002\u7528\u4e8e\u7279\u5b9a\u9700\u6c42\u3002<\/li>\n<li><strong>\u81ea\u5b9a\u4e49\u51fd\u6570<\/strong>\u53ef\u4ee5\u5b9e\u73b0\u66f4\u4e3a\u7cbe\u786e\u7684\u56db\u820d\u4e94\u5165\u89c4\u5219\uff0c\u4f46\u4ee3\u7801\u590d\u6742\u5ea6\u8f83\u9ad8\u3002<\/li>\n<\/ul>\n<p><p>\u901a\u8fc7\u5408\u7406\u4f7f\u7528\u8fd9\u4e9b\u65b9\u6cd5\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u5728 Python \u4e2d\u9ad8\u6548\u5730\u5904\u7406\u6d6e\u70b9\u6570\u4e0e\u6574\u578b\u4e4b\u95f4\u7684\u8f6c\u6362\u548c\u56db\u820d\u4e94\u5165\u64cd\u4f5c\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u5b9e\u73b0\u6d6e\u70b9\u6570\u7684\u56db\u820d\u4e94\u5165\u8f6c\u6362\u4e3a\u6574\u6570\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u5185\u7f6e\u7684<code>round()<\/code>\u51fd\u6570\u5bf9\u6d6e\u70b9\u6570\u8fdb\u884c\u56db\u820d\u4e94\u5165\u3002\u8be5\u51fd\u6570\u53ef\u4ee5\u63a5\u53d7\u4e24\u4e2a\u53c2\u6570\uff0c\u7b2c\u4e00\u4e2a\u662f\u8981\u56db\u820d\u4e94\u5165\u7684\u6570\u5b57\uff0c\u7b2c\u4e8c\u4e2a\u662f\u53ef\u9009\u7684\u7cbe\u5ea6\u53c2\u6570\uff0c\u9ed8\u8ba4\u503c\u4e3a0\uff0c\u8868\u793a\u56db\u820d\u4e94\u5165\u5230\u6700\u63a5\u8fd1\u7684\u6574\u6570\u3002\u4f8b\u5982\uff0c<code>round(3.6)<\/code>\u5c06\u8fd4\u56de4\uff0c\u800c<code>round(3.4)<\/code>\u5c06\u8fd4\u56de3\u3002<\/p>\n<p><strong>\u6709\u6ca1\u6709\u5176\u4ed6\u65b9\u6cd5\u53ef\u4ee5\u5c06\u6d6e\u70b9\u6570\u8f6c\u4e3a\u6574\u6570\u800c\u4e0d\u4f7f\u7528round\u51fd\u6570\uff1f<\/strong><br \/>\u9664\u4e86<code>round()<\/code>\u51fd\u6570\u5916\uff0cPython\u8fd8\u63d0\u4f9b\u4e86\u5176\u4ed6\u51e0\u79cd\u65b9\u6cd5\u6765\u5c06\u6d6e\u70b9\u6570\u8f6c\u6362\u4e3a\u6574\u6570\u3002\u6bd4\u5982\uff0c\u4f7f\u7528<code>int()<\/code>\u51fd\u6570\u53ef\u4ee5\u76f4\u63a5\u5c06\u6d6e\u70b9\u6570\u5411\u4e0b\u53d6\u6574\uff0c\u800c\u4f7f\u7528<code>math.ceil()<\/code>\u548c<code>math.floor()<\/code>\u53ef\u4ee5\u5206\u522b\u5b9e\u73b0\u5411\u4e0a\u53d6\u6574\u548c\u5411\u4e0b\u53d6\u6574\u7684\u529f\u80fd\u3002\u8fd9\u6837\u53ef\u4ee5\u6839\u636e\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\u3002<\/p>\n<p><strong>\u56db\u820d\u4e94\u5165\u7684\u89c4\u5219\u662f\u4ec0\u4e48\uff0cPython\u4e2d\u7684round\u51fd\u6570\u662f\u5982\u4f55\u5b9e\u73b0\u7684\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c<code>round()<\/code>\u51fd\u6570\u9075\u5faa\u201c\u94f6\u884c\u5bb6\u820d\u5165\u6cd5\u201d\uff08\u4e5f\u79f0\u4e3a\u201c\u5076\u6570\u820d\u5165\u201d\uff09\u3002\u5f53\u6d6e\u70b9\u6570\u6b63\u597d\u4f4d\u4e8e\u4e24\u4e2a\u6574\u6570\u4e4b\u95f4\u65f6\uff0cPython\u4f1a\u5c06\u5176\u820d\u5165\u5230\u6700\u8fd1\u7684\u5076\u6570\u3002\u4f8b\u5982\uff0c<code>round(2.5)<\/code>\u548c<code>round(3.5)<\/code>\u90fd\u4f1a\u8fd4\u56de\u76f8\u5e94\u7684\u5076\u65702\u548c4\u3002\u8fd9\u79cd\u820d\u5165\u65b9\u5f0f\u6709\u52a9\u4e8e\u51cf\u5c11\u7d2f\u79ef\u8bef\u5dee\uff0c\u7279\u522b\u662f\u5728\u5927\u91cf\u6570\u636e\u5904\u7406\u65f6\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Python \u6d6e\u70b9\u578b\u8f6c\u5316\u4e3a\u6574\u578b\u5982\u4f55\u56db\u820d\u4e94\u5165\uff0c\u53ef\u4ee5\u4f7f\u7528 round() \u51fd\u6570\u3001int() \u51fd\u6570\u4ee5\u53ca math.f [&hellip;]","protected":false},"author":3,"featured_media":1141968,"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\/1141960"}],"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=1141960"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1141960\/revisions"}],"predecessor-version":[{"id":1141969,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1141960\/revisions\/1141969"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1141968"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1141960"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1141960"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1141960"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}