{"id":969901,"date":"2024-12-27T05:21:11","date_gmt":"2024-12-26T21:21:11","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/969901.html"},"modified":"2024-12-27T05:21:12","modified_gmt":"2024-12-26T21:21:12","slug":"python%e5%a6%82%e4%bd%95%e7%bc%96%e5%86%99%e7%ae%80%e5%8d%95%e5%8a%a0%e6%b3%95","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/969901.html","title":{"rendered":"python\u5982\u4f55\u7f16\u5199\u7b80\u5355\u52a0\u6cd5"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24183947\/96b3572e-37df-4e3f-be20-ffdfc2706d0d.webp\" alt=\"python\u5982\u4f55\u7f16\u5199\u7b80\u5355\u52a0\u6cd5\" \/><\/p>\n<p><p> <strong>\u5728Python\u4e2d\u7f16\u5199\u7b80\u5355\u7684\u52a0\u6cd5\u7a0b\u5e8f\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u4f7f\u7528\u52a0\u6cd5\u8fd0\u7b97\u7b26\u201c+\u201d\u5373\u53ef\u5b9e\u73b0\u3001\u4f7f\u7528input\u51fd\u6570\u83b7\u53d6\u7528\u6237\u8f93\u5165\u7684\u4e24\u4e2a\u6570\u5b57\u3001\u5c06\u8fd9\u4e24\u4e2a\u6570\u5b57\u76f8\u52a0\u5e76\u8f93\u51fa\u7ed3\u679c\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684Python\u52a0\u6cd5\u7a0b\u5e8f\u793a\u4f8b\uff1a<\/strong><\/p>\n<\/p>\n<p><p>\u8981\u5728Python\u4e2d\u7f16\u5199\u4e00\u4e2a\u7b80\u5355\u7684\u52a0\u6cd5\u7a0b\u5e8f\uff0c\u9996\u5148\u9700\u8981\u4e86\u89e3Python\u7684\u57fa\u672c\u6570\u636e\u7c7b\u578b\u548c\u8f93\u5165\u8f93\u51fa\u529f\u80fd\u3002Python\u662f\u4e00\u79cd\u9ad8\u7ea7\u7f16\u7a0b\u8bed\u8a00\uff0c\u63d0\u4f9b\u4e86\u7b80\u5355\u7684\u8bed\u6cd5\u548c\u4e30\u5bcc\u7684\u5e93\uff0c\u4f7f\u5f97\u6570\u636e\u64cd\u4f5c\u53d8\u5f97\u65b9\u4fbf\u5feb\u6377\u3002\u7f16\u5199\u52a0\u6cd5\u7a0b\u5e8f\u7684\u5173\u952e\u6b65\u9aa4\u5305\u62ec\uff1a\u63a5\u53d7\u7528\u6237\u8f93\u5165\u3001\u5c06\u8f93\u5165\u8f6c\u6362\u4e3a\u6570\u5b57\u3001\u8fdb\u884c\u52a0\u6cd5\u8fd0\u7b97\u5e76\u8f93\u51fa\u7ed3\u679c\u3002\u5728\u6b64\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4eec\u8fd8\u53ef\u4ee5\u4f7f\u7528\u5f02\u5e38\u5904\u7406\u6765\u786e\u4fdd\u7528\u6237\u8f93\u5165\u7684\u6709\u6548\u6027\uff0c\u907f\u514d\u8f93\u5165\u975e\u6570\u5b57\u5b57\u7b26\u5bfc\u81f4\u7a0b\u5e8f\u5d29\u6e83\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u4f7f\u7528\u57fa\u672c\u52a0\u6cd5\u8fd0\u7b97\u7b26<\/p>\n<\/p>\n<p><p>Python\u4e2d\u7684\u52a0\u6cd5\u8fd0\u7b97\u7b26\u662f\u201c+\u201d\uff0c\u5b83\u7528\u4e8e\u5c06\u4e24\u4e2a\u6570\u5b57\u76f8\u52a0\u3002\u7f16\u5199\u4e00\u4e2a\u7b80\u5355\u7684\u52a0\u6cd5\u7a0b\u5e8f\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u5b9e\u73b0\uff1a<\/p>\n<\/p>\n<ol>\n<li><strong>\u63a5\u53d7\u7528\u6237\u8f93\u5165<\/strong>\uff1a\u4f7f\u7528<code>input()<\/code>\u51fd\u6570\u4ece\u7528\u6237\u90a3\u91cc\u83b7\u53d6\u4e24\u4e2a\u6570\u5b57\u3002<\/li>\n<li><strong>\u8f6c\u6362\u6570\u636e\u7c7b\u578b<\/strong>\uff1a\u56e0\u4e3a<code>input()<\/code>\u51fd\u6570\u8fd4\u56de\u7684\u662f\u5b57\u7b26\u4e32\u7c7b\u578b\uff0c\u9700\u8981\u4f7f\u7528<code>int()<\/code>\u6216<code>float()<\/code>\u51fd\u6570\u5c06\u5176\u8f6c\u6362\u4e3a\u6570\u5b57\u7c7b\u578b\u3002<\/li>\n<li><strong>\u6267\u884c\u52a0\u6cd5\u8fd0\u7b97<\/strong>\uff1a\u5c06\u8f6c\u6362\u540e\u7684\u6570\u5b57\u76f8\u52a0\u3002<\/li>\n<li><strong>\u8f93\u51fa\u7ed3\u679c<\/strong>\uff1a\u4f7f\u7528<code>print()<\/code>\u51fd\u6570\u8f93\u51fa\u52a0\u6cd5\u7ed3\u679c\u3002<\/li>\n<\/ol>\n<p><p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u52a0\u6cd5\u7a0b\u5e8f\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u83b7\u53d6\u7528\u6237\u8f93\u5165<\/p>\n<p>num1 = input(&quot;\u8bf7\u8f93\u5165\u7b2c\u4e00\u4e2a\u6570\u5b57: &quot;)<\/p>\n<p>num2 = input(&quot;\u8bf7\u8f93\u5165\u7b2c\u4e8c\u4e2a\u6570\u5b57: &quot;)<\/p>\n<h2><strong>\u8f6c\u6362\u4e3a\u6574\u6570\u6216\u6d6e\u70b9\u6570<\/strong><\/h2>\n<p>num1 = float(num1)<\/p>\n<p>num2 = float(num2)<\/p>\n<h2><strong>\u8ba1\u7b97\u548c<\/strong><\/h2>\n<p>sum = num1 + num2<\/p>\n<h2><strong>\u8f93\u51fa\u7ed3\u679c<\/strong><\/h2>\n<p>print(&quot;\u4e24\u4e2a\u6570\u5b57\u7684\u548c\u662f:&quot;, sum)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\uff0c\u6211\u4eec\u53ef\u4ee5\u5f88\u5bb9\u6613\u5730\u5b9e\u73b0\u4e24\u4e2a\u6570\u5b57\u7684\u52a0\u6cd5\u8fd0\u7b97\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u786e\u4fdd\u7528\u6237\u8f93\u5165\u7684\u503c\u53ef\u4ee5\u6210\u529f\u8f6c\u6362\u4e3a\u6570\u5b57\u7c7b\u578b\uff0c\u5426\u5219\u7a0b\u5e8f\u5c06\u629b\u51fa\u5f02\u5e38\u3002<\/p>\n<\/p>\n<p><p>\u4e8c\u3001\u5904\u7406\u5f02\u5e38\u8f93\u5165<\/p>\n<\/p>\n<p><p>\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u7528\u6237\u53ef\u80fd\u4f1a\u8f93\u5165\u65e0\u6548\u6570\u636e\uff08\u4f8b\u5982\u975e\u6570\u5b57\u5b57\u7b26\uff09\u3002\u4e3a\u4e86\u63d0\u9ad8\u7a0b\u5e8f\u7684\u5065\u58ee\u6027\uff0c\u53ef\u4ee5\u901a\u8fc7\u5f02\u5e38\u5904\u7406\u6765\u6355\u83b7\u8fd9\u79cd\u9519\u8bef\u5e76\u63d0\u793a\u7528\u6237\u91cd\u65b0\u8f93\u5165\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">while True:<\/p>\n<p>    try:<\/p>\n<p>        num1 = float(input(&quot;\u8bf7\u8f93\u5165\u7b2c\u4e00\u4e2a\u6570\u5b57: &quot;))<\/p>\n<p>        num2 = float(input(&quot;\u8bf7\u8f93\u5165\u7b2c\u4e8c\u4e2a\u6570\u5b57: &quot;))<\/p>\n<p>        break<\/p>\n<p>    except ValueError:<\/p>\n<p>        print(&quot;\u8f93\u5165\u65e0\u6548\uff0c\u8bf7\u8f93\u5165\u6570\u5b57\u3002&quot;)<\/p>\n<p>sum = num1 + num2<\/p>\n<p>print(&quot;\u4e24\u4e2a\u6570\u5b57\u7684\u548c\u662f:&quot;, sum)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u4f7f\u7528<code>try<\/code>\u548c<code>except<\/code>\u5757\uff0c\u6211\u4eec\u53ef\u4ee5\u6355\u83b7\u5230<code>ValueError<\/code>\u5f02\u5e38\uff0c\u4ece\u800c\u907f\u514d\u7a0b\u5e8f\u5d29\u6e83\uff0c\u5e76\u63d0\u793a\u7528\u6237\u91cd\u65b0\u8f93\u5165\u6709\u6548\u6570\u636e\u3002<\/p>\n<\/p>\n<p><p>\u4e09\u3001\u4f7f\u7528\u51fd\u6570\u5c01\u88c5\u52a0\u6cd5\u903b\u8f91<\/p>\n<\/p>\n<p><p>\u4e3a\u4e86\u63d0\u9ad8\u4ee3\u7801\u7684\u53ef\u91cd\u7528\u6027\u548c\u53ef\u8bfb\u6027\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06\u52a0\u6cd5\u903b\u8f91\u5c01\u88c5\u5230\u4e00\u4e2a\u51fd\u6570\u4e2d\uff0c\u8fd9\u6837\u53ef\u4ee5\u5728\u9700\u8981\u65f6\u591a\u6b21\u8c03\u7528\u8be5\u51fd\u6570\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def add_numbers():<\/p>\n<p>    while True:<\/p>\n<p>        try:<\/p>\n<p>            num1 = float(input(&quot;\u8bf7\u8f93\u5165\u7b2c\u4e00\u4e2a\u6570\u5b57: &quot;))<\/p>\n<p>            num2 = float(input(&quot;\u8bf7\u8f93\u5165\u7b2c\u4e8c\u4e2a\u6570\u5b57: &quot;))<\/p>\n<p>            break<\/p>\n<p>        except ValueError:<\/p>\n<p>            print(&quot;\u8f93\u5165\u65e0\u6548\uff0c\u8bf7\u8f93\u5165\u6570\u5b57\u3002&quot;)<\/p>\n<p>    return num1 + num2<\/p>\n<p>result = add_numbers()<\/p>\n<p>print(&quot;\u4e24\u4e2a\u6570\u5b57\u7684\u548c\u662f:&quot;, result)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u4f7f\u7528\u51fd\u6570\uff0c\u6211\u4eec\u53ef\u4ee5\u66f4\u597d\u5730\u7ec4\u7ec7\u4ee3\u7801\uff0c\u5e76\u4f7f\u5176\u66f4\u6613\u4e8e\u7ef4\u62a4\u548c\u6269\u5c55\u3002<\/p>\n<\/p>\n<p><p>\u56db\u3001\u6269\u5c55\u529f\u80fd\uff1a\u5b9e\u73b0\u591a\u9879\u52a0\u6cd5<\/p>\n<\/p>\n<p><p>\u9664\u4e86\u4e24\u4e2a\u6570\u5b57\u7684\u52a0\u6cd5\u5916\uff0c\u6211\u4eec\u8fd8\u53ef\u4ee5\u6269\u5c55\u7a0b\u5e8f\uff0c\u4f7f\u5176\u80fd\u591f\u8ba1\u7b97\u591a\u4e2a\u6570\u5b57\u7684\u548c\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u4f7f\u7528\u5217\u8868\u5b58\u50a8\u7528\u6237\u8f93\u5165\u7684\u6570\u5b57\uff0c\u5faa\u73af\u904d\u5386\u5217\u8868\u5e76\u7d2f\u52a0\u6bcf\u4e2a\u6570\u5b57\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def add_multiple_numbers():<\/p>\n<p>    numbers = []<\/p>\n<p>    while True:<\/p>\n<p>        user_input = input(&quot;\u8bf7\u8f93\u5165\u4e00\u4e2a\u6570\u5b57\uff08\u6216\u8f93\u5165&#39;q&#39;\u7ed3\u675f\uff09: &quot;)<\/p>\n<p>        if user_input.lower() == &#39;q&#39;:<\/p>\n<p>            break<\/p>\n<p>        try:<\/p>\n<p>            number = float(user_input)<\/p>\n<p>            numbers.append(number)<\/p>\n<p>        except ValueError:<\/p>\n<p>            print(&quot;\u8f93\u5165\u65e0\u6548\uff0c\u8bf7\u8f93\u5165\u6570\u5b57\u3002&quot;)<\/p>\n<p>    return sum(numbers)<\/p>\n<p>result = add_multiple_numbers()<\/p>\n<p>print(&quot;\u8fd9\u4e9b\u6570\u5b57\u7684\u548c\u662f:&quot;, result)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u4e00\u4e2a\u5217\u8868\u6765\u5b58\u50a8\u7528\u6237\u8f93\u5165\u7684\u6570\u5b57\uff0c\u5e76\u4f7f\u7528\u4e00\u4e2a<code>while<\/code>\u5faa\u73af\u6765\u63a5\u53d7\u7528\u6237\u7684\u8f93\u5165\uff0c\u76f4\u5230\u7528\u6237\u8f93\u5165&#39;q&#39;\u4e3a\u6b62\u3002\u7136\u540e\uff0c\u4f7f\u7528\u5185\u7f6e\u7684<code>sum()<\/code>\u51fd\u6570\u8ba1\u7b97\u5217\u8868\u4e2d\u6240\u6709\u6570\u5b57\u7684\u548c\u3002<\/p>\n<\/p>\n<p><p>\u4e94\u3001\u4f7f\u7528\u547d\u4ee4\u884c\u53c2\u6570\u8fdb\u884c\u52a0\u6cd5\u8fd0\u7b97<\/p>\n<\/p>\n<p><p>\u5bf9\u4e8e\u66f4\u9ad8\u7ea7\u7684\u5e94\u7528\uff0c\u53ef\u4ee5\u4f7f\u7528Python\u7684<code>sys<\/code>\u6a21\u5757\u4ece\u547d\u4ee4\u884c\u83b7\u53d6\u53c2\u6570\u5e76\u8fdb\u884c\u52a0\u6cd5\u8fd0\u7b97\uff0c\u8fd9\u5728\u81ea\u52a8\u5316\u811a\u672c\u4e2d\u975e\u5e38\u6709\u7528\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import sys<\/p>\n<p>def add_from_command_line(args):<\/p>\n<p>    try:<\/p>\n<p>        numbers = [float(arg) for arg in args]<\/p>\n<p>        return sum(numbers)<\/p>\n<p>    except ValueError:<\/p>\n<p>        print(&quot;\u6240\u6709\u8f93\u5165\u5fc5\u987b\u662f\u6570\u5b57\u3002&quot;)<\/p>\n<p>        return None<\/p>\n<p>if __name__ == &quot;__m<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>n__&quot;:<\/p>\n<p>    if len(sys.argv) &lt; 3:<\/p>\n<p>        print(&quot;\u8bf7\u63d0\u4f9b\u81f3\u5c11\u4e24\u4e2a\u6570\u5b57\u4f5c\u4e3a\u53c2\u6570\u3002&quot;)<\/p>\n<p>    else:<\/p>\n<p>        result = add_from_command_line(sys.argv[1:])<\/p>\n<p>        if result is not None:<\/p>\n<p>            print(&quot;\u8f93\u5165\u6570\u5b57\u7684\u548c\u662f:&quot;, result)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u901a\u8fc7<code>sys.argv<\/code>\u83b7\u53d6\u547d\u4ee4\u884c\u53c2\u6570\uff0c\u5e76\u5c06\u5176\u4f20\u9012\u7ed9<code>add_from_command_line()<\/code>\u51fd\u6570\u8fdb\u884c\u5904\u7406\u3002\u8fd9\u6837\u53ef\u4ee5\u65b9\u4fbf\u5730\u5728\u547d\u4ee4\u884c\u4e2d\u4f7f\u7528\u811a\u672c\u8fdb\u884c\u52a0\u6cd5\u8fd0\u7b97\u3002<\/p>\n<\/p>\n<p><p>\u901a\u8fc7\u8fd9\u4e9b\u6b65\u9aa4\uff0c\u6211\u4eec\u53ef\u4ee5\u5728Python\u4e2d\u7f16\u5199\u4e00\u4e2a\u529f\u80fd\u4e30\u5bcc\u7684\u52a0\u6cd5\u7a0b\u5e8f\uff0c\u4ece\u7b80\u5355\u7684\u4e24\u4e2a\u6570\u5b57\u76f8\u52a0\u5230\u5904\u7406\u591a\u4e2a\u6570\u5b57\u751a\u81f3\u4f7f\u7528\u547d\u4ee4\u884c\u53c2\u6570\u8fdb\u884c\u8fd0\u7b97\u3002\u8fd9\u4e9b\u6280\u80fd\u4e0d\u4ec5\u6709\u52a9\u4e8e\u7406\u89e3Python\u7684\u57fa\u672c\u8bed\u6cd5\u548c\u529f\u80fd\uff0c\u8fd8\u4e3a\u66f4\u590d\u6742\u7684\u7f16\u7a0b\u4efb\u52a1\u6253\u4e0b\u57fa\u7840\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u5b9e\u73b0\u7b80\u5355\u7684\u52a0\u6cd5\u8fd0\u7b97\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u201c+\u201d\u8fd0\u7b97\u7b26\u6765\u8fdb\u884c\u7b80\u5355\u7684\u52a0\u6cd5\u8fd0\u7b97\u3002\u9996\u5148\uff0c\u60a8\u53ef\u4ee5\u5b9a\u4e49\u4e24\u4e2a\u53d8\u91cf\u6765\u5b58\u50a8\u8981\u76f8\u52a0\u7684\u6570\u5b57\uff0c\u7136\u540e\u4f7f\u7528\u201c+\u201d\u8fd0\u7b97\u7b26\u5c06\u5b83\u4eec\u76f8\u52a0\u5e76\u6253\u5370\u7ed3\u679c\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\u4ee3\u7801\uff1a  <\/p>\n<pre><code class=\"language-python\">a = 5\nb = 3\nresult = a + b\nprint(&quot;\u7ed3\u679c\u662f:&quot;, result)\n<\/code><\/pre>\n<p><strong>Python\u662f\u5426\u652f\u6301\u591a\u79cd\u6570\u636e\u7c7b\u578b\u8fdb\u884c\u52a0\u6cd5\uff1f<\/strong><br \/>\u662f\u7684\uff0cPython\u652f\u6301\u591a\u79cd\u6570\u636e\u7c7b\u578b\u8fdb\u884c\u52a0\u6cd5\u8fd0\u7b97\uff0c\u5305\u62ec\u6574\u6570\u3001\u6d6e\u70b9\u6570\u548c\u5b57\u7b26\u4e32\u3002\u5f53\u60a8\u5c1d\u8bd5\u5bf9\u4e0d\u540c\u7c7b\u578b\u7684\u6570\u636e\u8fdb\u884c\u52a0\u6cd5\u65f6\uff0cPython\u4f1a\u6839\u636e\u7c7b\u578b\u8fdb\u884c\u76f8\u5e94\u7684\u5904\u7406\u3002\u4f8b\u5982\uff0c\u4e24\u4e2a\u5b57\u7b26\u4e32\u76f8\u52a0\u4f1a\u8fdb\u884c\u62fc\u63a5\uff0c\u800c\u6570\u5b57\u76f8\u52a0\u4f1a\u5f97\u5230\u6570\u5b66\u4e0a\u7684\u603b\u548c\u3002\u8bf7\u6ce8\u610f\uff0c\u4e0d\u540c\u7c7b\u578b\u7684\u52a0\u6cd5\u8fd0\u7b97\u53ef\u80fd\u4f1a\u5f15\u53d1\u9519\u8bef\uff0c\u56e0\u6b64\u5728\u6267\u884c\u52a0\u6cd5\u65f6\u786e\u4fdd\u6570\u636e\u7c7b\u578b\u7684\u5339\u914d\u662f\u975e\u5e38\u91cd\u8981\u7684\u3002<\/p>\n<p><strong>\u5982\u4f55\u5904\u7406\u7528\u6237\u8f93\u5165\u7684\u52a0\u6cd5\u8fd0\u7b97\uff1f<\/strong><br \/>\u60a8\u53ef\u4ee5\u4f7f\u7528<code>input()<\/code>\u51fd\u6570\u6765\u63a5\u6536\u7528\u6237\u8f93\u5165\u7684\u6570\u5b57\uff0c\u5e76\u5c06\u5176\u8f6c\u6362\u4e3a\u6574\u6570\u6216\u6d6e\u70b9\u6570\u8fdb\u884c\u52a0\u6cd5\u8fd0\u7b97\u3002\u4ee5\u4e0b\u793a\u4f8b\u5c55\u793a\u4e86\u5982\u4f55\u5b9e\u73b0\u8fd9\u4e00\u8fc7\u7a0b\uff1a  <\/p>\n<pre><code class=\"language-python\">num1 = float(input(&quot;\u8bf7\u8f93\u5165\u7b2c\u4e00\u4e2a\u6570\u5b57: &quot;))\nnum2 = float(input(&quot;\u8bf7\u8f93\u5165\u7b2c\u4e8c\u4e2a\u6570\u5b57: &quot;))\nsum_result = num1 + num2\nprint(&quot;\u4e24\u6570\u4e4b\u548c\u4e3a:&quot;, sum_result)\n<\/code><\/pre>\n<p>\u8fd9\u6837\uff0c\u7a0b\u5e8f\u80fd\u591f\u6839\u636e\u7528\u6237\u8f93\u5165\u7684\u6570\u5b57\u8fdb\u884c\u52a0\u6cd5\u8fd0\u7b97\uff0c\u63d0\u4f9b\u7075\u6d3b\u6027\u548c\u4e92\u52a8\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python\u4e2d\u7f16\u5199\u7b80\u5355\u7684\u52a0\u6cd5\u7a0b\u5e8f\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u4f7f\u7528\u52a0\u6cd5\u8fd0\u7b97\u7b26\u201c+\u201d\u5373\u53ef\u5b9e\u73b0\u3001\u4f7f\u7528input\u51fd\u6570\u83b7\u53d6\u7528\u6237\u8f93\u5165\u7684 [&hellip;]","protected":false},"author":3,"featured_media":969908,"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\/969901"}],"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=969901"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/969901\/revisions"}],"predecessor-version":[{"id":969911,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/969901\/revisions\/969911"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/969908"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=969901"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=969901"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=969901"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}