{"id":1095370,"date":"2025-01-08T14:50:28","date_gmt":"2025-01-08T06:50:28","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1095370.html"},"modified":"2025-01-08T14:50:30","modified_gmt":"2025-01-08T06:50:30","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8python%e4%b8%ad%e8%be%93%e5%85%a5%e5%a4%9a%e4%b8%aa%e6%95%b0%e5%ad%97-2","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1095370.html","title":{"rendered":"\u5982\u4f55\u5728python\u4e2d\u8f93\u5165\u591a\u4e2a\u6570\u5b57"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24211042\/b4557fb0-cb35-4e65-9755-70f4eff51fdd.webp\" alt=\"\u5982\u4f55\u5728python\u4e2d\u8f93\u5165\u591a\u4e2a\u6570\u5b57\" \/><\/p>\n<p><p> <strong>\u5728Python\u4e2d\u8f93\u5165\u591a\u4e2a\u6570\u5b57\u6709\u591a\u79cd\u65b9\u6cd5\uff0c\u5305\u62ec\u4f7f\u7528input\u51fd\u6570\u3001\u5faa\u73af\u3001\u5217\u8868\u89e3\u6790\u7b49\uff0c\u5177\u4f53\u65b9\u6cd5\u6709\uff1a\u4f7f\u7528input\u51fd\u6570\u8bfb\u53d6\u4e00\u884c\u5e76\u5206\u5272\u3001\u4f7f\u7528\u591a\u6b21input\u8bfb\u53d6\u3001\u4f7f\u7528\u5217\u8868\u89e3\u6790\u3002\u8be6\u7ec6\u6765\u8bf4\uff0c\u53ef\u4ee5\u901a\u8fc7input\u51fd\u6570\u8bfb\u53d6\u4e00\u884c\u8f93\u5165\u5e76\u4f7f\u7528split\u65b9\u6cd5\u5206\u5272\u6210\u591a\u4e2a\u6570\u5b57\u3002<\/strong><\/p>\n<\/p>\n<p><p>\u4e00\u3001\u4f7f\u7528input\u51fd\u6570\u8bfb\u53d6\u4e00\u884c\u5e76\u5206\u5272<\/p>\n<\/p>\n<p><p>\u8fd9\u662f\u6700\u5e38\u89c1\u7684\u65b9\u6cd5\u4e4b\u4e00\uff0c\u901a\u8fc7input\u51fd\u6570\u8bfb\u53d6\u4e00\u884c\u8f93\u5165\uff0c\u7136\u540e\u4f7f\u7528split\u65b9\u6cd5\u5c06\u8f93\u5165\u7684\u5b57\u7b26\u4e32\u5206\u5272\u6210\u591a\u4e2a\u6570\u5b57\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u8bfb\u53d6\u4e00\u884c\u8f93\u5165\uff0c\u5e76\u5c06\u5176\u5206\u5272\u4e3a\u591a\u4e2a\u6570\u5b57<\/p>\n<p>numbers = input(&quot;Enter numbers separated by space: &quot;).split()<\/p>\n<p>numbers = [int(num) for num in numbers]<\/p>\n<p>print(&quot;You entered:&quot;, numbers)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u7528\u6237\u8f93\u5165\u4e00\u884c\u6570\u5b57\uff0c\u7528\u7a7a\u683c\u5206\u9694\u3002input\u51fd\u6570\u8bfb\u53d6\u6574\u884c\u8f93\u5165\uff0c\u5e76\u8fd4\u56de\u4e00\u4e2a\u5b57\u7b26\u4e32\u3002split\u65b9\u6cd5\u5c06\u5b57\u7b26\u4e32\u5206\u5272\u6210\u591a\u4e2a\u5b50\u5b57\u7b26\u4e32\uff0c\u7136\u540e\u4f7f\u7528\u5217\u8868\u89e3\u6790\u5c06\u6bcf\u4e2a\u5b50\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u6574\u6570\u3002<\/p>\n<\/p>\n<p><p>\u4e8c\u3001\u4f7f\u7528\u591a\u6b21input\u8bfb\u53d6<\/p>\n<\/p>\n<p><p>\u5982\u679c\u4f60\u5e0c\u671b\u7528\u6237\u4e00\u6b21\u8f93\u5165\u4e00\u4e2a\u6570\u5b57\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e2a\u5faa\u73af\u6765\u591a\u6b21\u8c03\u7528input\u51fd\u6570\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u8bfb\u53d6\u591a\u4e2a\u6570\u5b57\uff0c\u76f4\u5230\u7528\u6237\u8f93\u5165\u7a7a\u5b57\u7b26\u4e32<\/p>\n<p>numbers = []<\/p>\n<p>while True:<\/p>\n<p>    num = input(&quot;Enter a number (or press Enter to finish): &quot;)<\/p>\n<p>    if num == &quot;&quot;:<\/p>\n<p>        break<\/p>\n<p>    numbers.append(int(num))<\/p>\n<p>print(&quot;You entered:&quot;, numbers)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u7a0b\u5e8f\u4e0d\u65ad\u8bfb\u53d6\u7528\u6237\u8f93\u5165\uff0c\u76f4\u5230\u7528\u6237\u8f93\u5165\u7a7a\u5b57\u7b26\u4e32\u4e3a\u6b62\u3002\u6bcf\u6b21\u8f93\u5165\u7684\u6570\u5b57\u90fd\u88ab\u6dfb\u52a0\u5230\u5217\u8868\u4e2d\u3002<\/p>\n<\/p>\n<p><p>\u4e09\u3001\u4f7f\u7528\u5217\u8868\u89e3\u6790<\/p>\n<\/p>\n<p><p>\u5982\u679c\u4f60\u5df2\u7ecf\u77e5\u9053\u9700\u8981\u8f93\u5165\u7684\u6570\u5b57\u4e2a\u6570\uff0c\u53ef\u4ee5\u4f7f\u7528\u5217\u8868\u89e3\u6790\u6765\u7b80\u5316\u4ee3\u7801\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u8bfb\u53d6\u6307\u5b9a\u6570\u91cf\u7684\u6570\u5b57<\/p>\n<p>n = int(input(&quot;How many numbers do you want to enter? &quot;))<\/p>\n<p>numbers = [int(input(f&quot;Enter number {i+1}: &quot;)) for i in range(n)]<\/p>\n<p>print(&quot;You entered:&quot;, numbers)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u9996\u5148\u8bfb\u53d6\u7528\u6237\u5e0c\u671b\u8f93\u5165\u7684\u6570\u5b57\u4e2a\u6570\uff0c\u7136\u540e\u4f7f\u7528\u5217\u8868\u89e3\u6790\u5728\u4e00\u4e2a\u5faa\u73af\u4e2d\u8bfb\u53d6\u6bcf\u4e2a\u6570\u5b57\u3002<\/p>\n<\/p>\n<p><p>\u56db\u3001\u4ece\u6587\u4ef6\u4e2d\u8bfb\u53d6\u591a\u4e2a\u6570\u5b57<\/p>\n<\/p>\n<p><p>\u6709\u65f6\u5019\uff0c\u6570\u5b57\u8f93\u5165\u53ef\u80fd\u6765\u81ea\u6587\u4ef6\u800c\u4e0d\u662f\u7528\u6237\u8f93\u5165\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528Python\u7684\u6587\u4ef6\u5904\u7406\u529f\u80fd\u6765\u5b9e\u73b0\u8fd9\u4e00\u70b9\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u4ece\u6587\u4ef6\u8bfb\u53d6\u6570\u5b57<\/p>\n<p>with open(&quot;numbers.txt&quot;, &quot;r&quot;) as file:<\/p>\n<p>    numbers = file.read().split()<\/p>\n<p>    numbers = [int(num) for num in numbers]<\/p>\n<p>print(&quot;Numbers read from file:&quot;, numbers)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u7a0b\u5e8f\u4ece\u540d\u4e3a\u201cnumbers.txt\u201d\u7684\u6587\u4ef6\u4e2d\u8bfb\u53d6\u6240\u6709\u5185\u5bb9\uff0c\u5e76\u4f7f\u7528split\u65b9\u6cd5\u5c06\u5176\u5206\u5272\u6210\u591a\u4e2a\u6570\u5b57\u3002<\/p>\n<\/p>\n<p><p>\u4e94\u3001\u4f7f\u7528map\u51fd\u6570<\/p>\n<\/p>\n<p><p>map\u51fd\u6570\u662fPython\u5185\u7f6e\u7684\u4e00\u4e2a\u975e\u5e38\u5f3a\u5927\u7684\u5de5\u5177\uff0c\u53ef\u4ee5\u5c06\u4e00\u4e2a\u51fd\u6570\u5e94\u7528\u5230\u4e00\u4e2a\u53ef\u8fed\u4ee3\u5bf9\u8c61\u7684\u6bcf\u4e00\u4e2a\u5143\u7d20\u4e0a\u3002\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u6574\u6570\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u4f7f\u7528map\u51fd\u6570<\/p>\n<p>numbers = list(map(int, input(&quot;Enter numbers separated by space: &quot;).split()))<\/p>\n<p>print(&quot;You entered:&quot;, numbers)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0cmap\u51fd\u6570\u5c06int\u51fd\u6570\u5e94\u7528\u5230\u8f93\u5165\u7684\u6bcf\u4e2a\u5b50\u5b57\u7b26\u4e32\u4e0a\uff0c\u7136\u540e\u5c06\u7ed3\u679c\u8f6c\u6362\u4e3a\u4e00\u4e2a\u5217\u8868\u3002<\/p>\n<\/p>\n<p><p>\u516d\u3001\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f<\/p>\n<\/p>\n<p><p>\u5982\u679c\u8f93\u5165\u7684\u6570\u5b57\u53ef\u80fd\u5305\u542b\u5176\u4ed6\u5b57\u7b26\uff08\u5982\u9017\u53f7\u3001\u5206\u53f7\u7b49\uff09\uff0c\u53ef\u4ee5\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u6765\u63d0\u53d6\u6570\u5b57\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import re<\/p>\n<h2><strong>\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u63d0\u53d6\u6570\u5b57<\/strong><\/h2>\n<p>input_str = input(&quot;Enter numbers separated by spaces, commas, or semicolons: &quot;)<\/p>\n<p>numbers = list(map(int, re.findall(r&#39;\\d+&#39;, input_str)))<\/p>\n<p>print(&quot;You entered:&quot;, numbers)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0cre.findall\u51fd\u6570\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u63d0\u53d6\u8f93\u5165\u5b57\u7b26\u4e32\u4e2d\u7684\u6240\u6709\u6570\u5b57\u3002<\/p>\n<\/p>\n<p><p>\u4e03\u3001\u4f7f\u7528numpy\u5e93<\/p>\n<\/p>\n<p><p>\u5982\u679c\u4f60\u9700\u8981\u5904\u7406\u5927\u91cf\u6570\u5b57\uff0c\u53ef\u4ee5\u8003\u8651\u4f7f\u7528numpy\u5e93\u3002\u5b83\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u6570\u7ec4\u5904\u7406\u529f\u80fd\uff0c\u5e76\u4e14\u6027\u80fd\u4f18\u5f02\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<h2><strong>\u4f7f\u7528numpy\u5904\u7406\u6570\u5b57<\/strong><\/h2>\n<p>numbers = np.array(input(&quot;Enter numbers separated by space: &quot;).split(), dtype=int)<\/p>\n<p>print(&quot;You entered:&quot;, numbers)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0cnumpy\u6570\u7ec4\u88ab\u7528\u6765\u5b58\u50a8\u8f93\u5165\u7684\u6570\u5b57\u3002numpy\u7684\u4f18\u70b9\u662f\u5b83\u53ef\u4ee5\u9ad8\u6548\u5730\u5904\u7406\u5927\u91cf\u6570\u636e\uff0c\u5e76\u4e14\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u6570\u7ec4\u64cd\u4f5c\u529f\u80fd\u3002<\/p>\n<\/p>\n<p><p>\u516b\u3001\u4f7f\u7528pandas\u5e93<\/p>\n<\/p>\n<p><p>\u5982\u679c\u6570\u5b57\u8f93\u5165\u9700\u8981\u8fdb\u4e00\u6b65\u7684\u6570\u636e\u5904\u7406\u548c\u5206\u6790\uff0c\u53ef\u4ee5\u4f7f\u7528pandas\u5e93\u3002pandas\u5e93\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u6570\u636e\u7ed3\u6784\u548c\u6570\u636e\u5206\u6790\u5de5\u5177\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<h2><strong>\u4f7f\u7528pandas\u5904\u7406\u6570\u5b57<\/strong><\/h2>\n<p>input_str = input(&quot;Enter numbers separated by space: &quot;)<\/p>\n<p>numbers = pd.Series(input_str.split(), dtype=int)<\/p>\n<p>print(&quot;You entered:&quot;, numbers)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0cpandas\u7684Series\u5bf9\u8c61\u88ab\u7528\u6765\u5b58\u50a8\u8f93\u5165\u7684\u6570\u5b57\u3002pandas\u7684\u4f18\u70b9\u662f\u5b83\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u6570\u636e\u5206\u6790\u548c\u5904\u7406\u529f\u80fd\uff0c\u975e\u5e38\u9002\u5408\u6570\u636e\u79d1\u5b66\u548c<a href=\"https:\/\/docs.pingcode.com\/ask\/59192.html\" target=\"_blank\">\u673a\u5668\u5b66\u4e60<\/a>\u5e94\u7528\u3002<\/p>\n<\/p>\n<p><p>\u4e5d\u3001\u4ece\u547d\u4ee4\u884c\u53c2\u6570\u8bfb\u53d6<\/p>\n<\/p>\n<p><p>\u6709\u65f6\u5019\uff0c\u8f93\u5165\u7684\u6570\u5b57\u53ef\u80fd\u6765\u81ea\u547d\u4ee4\u884c\u53c2\u6570\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528sys.argv\u6765\u8bfb\u53d6\u547d\u4ee4\u884c\u53c2\u6570\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import sys<\/p>\n<h2><strong>\u4ece\u547d\u4ee4\u884c\u53c2\u6570\u8bfb\u53d6\u6570\u5b57<\/strong><\/h2>\n<p>numbers = list(map(int, sys.argv[1:]))<\/p>\n<p>print(&quot;You entered:&quot;, numbers)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0csys.argv\u5305\u542b\u547d\u4ee4\u884c\u53c2\u6570\u5217\u8868\u3002\u7b2c\u4e00\u4e2a\u5143\u7d20\u662f\u811a\u672c\u540d\u79f0\uff0c\u540e\u7eed\u5143\u7d20\u662f\u547d\u4ee4\u884c\u53c2\u6570\u3002\u6211\u4eec\u4f7f\u7528map\u51fd\u6570\u5c06\u8fd9\u4e9b\u53c2\u6570\u8f6c\u6362\u4e3a\u6574\u6570\u3002<\/p>\n<\/p>\n<p><p>\u5341\u3001\u4f7f\u7528\u51fd\u6570\u5c01\u88c5<\/p>\n<\/p>\n<p><p>\u4e3a\u4e86\u63d0\u9ad8\u4ee3\u7801\u7684\u53ef\u91cd\u7528\u6027\uff0c\u53ef\u4ee5\u5c06\u8bfb\u53d6\u591a\u4e2a\u6570\u5b57\u7684\u903b\u8f91\u5c01\u88c5\u5230\u4e00\u4e2a\u51fd\u6570\u4e2d\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def read_numbers(prompt=&quot;Enter numbers separated by space: &quot;):<\/p>\n<p>    return list(map(int, input(prompt).split()))<\/p>\n<p>numbers = read_numbers()<\/p>\n<p>print(&quot;You entered:&quot;, numbers)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u5b9a\u4e49\u4e86\u4e00\u4e2a\u540d\u4e3aread_numbers\u7684\u51fd\u6570\uff0c\u8be5\u51fd\u6570\u8bfb\u53d6\u7528\u6237\u8f93\u5165\u5e76\u5c06\u5176\u8f6c\u6362\u4e3a\u6574\u6570\u5217\u8868\u3002\u8fd9\u6837\u53ef\u4ee5\u63d0\u9ad8\u4ee3\u7801\u7684\u53ef\u91cd\u7528\u6027\u548c\u53ef\u8bfb\u6027\u3002<\/p>\n<\/p>\n<p><p>\u603b\u7ed3<\/p>\n<\/p>\n<p><p>\u5728Python\u4e2d\u8f93\u5165\u591a\u4e2a\u6570\u5b57\u6709\u591a\u79cd\u65b9\u6cd5\uff0c\u9009\u62e9\u54ea\u79cd\u65b9\u6cd5\u53d6\u51b3\u4e8e\u5177\u4f53\u7684\u9700\u6c42\u548c\u573a\u666f\u3002\u65e0\u8bba\u662f\u901a\u8fc7input\u51fd\u6570\u8bfb\u53d6\u4e00\u884c\u8f93\u5165\u5e76\u5206\u5272\uff0c\u8fd8\u662f\u4f7f\u7528\u5faa\u73af\u591a\u6b21\u8c03\u7528input\u51fd\u6570\uff0c\u4ea6\u6216\u662f\u5229\u7528map\u51fd\u6570\u3001\u6b63\u5219\u8868\u8fbe\u5f0f\u3001numpy\u3001pandas\u7b49\u5e93\uff0c\u90fd\u53ef\u4ee5\u65b9\u4fbf\u5730\u5b9e\u73b0\u591a\u4e2a\u6570\u5b57\u7684\u8f93\u5165\u3002\u9009\u62e9\u9002\u5408\u81ea\u5df1\u9700\u6c42\u7684\u65b9\u6cd5\uff0c\u53ef\u4ee5\u63d0\u9ad8\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u548c\u6548\u7387\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u8f93\u5165\u591a\u4e2a\u6570\u5b57\u5e76\u5b58\u50a8\u5728\u5217\u8868\u4e2d\uff1f<\/strong><br \/>\u60a8\u53ef\u4ee5\u4f7f\u7528\u5185\u7f6e\u7684<code>input()<\/code>\u51fd\u6570\u6765\u63a5\u6536\u7528\u6237\u8f93\u5165\uff0c\u5c06\u8f93\u5165\u7684\u6570\u5b57\u7528\u7a7a\u683c\u6216\u9017\u53f7\u5206\u9694\u3002\u968f\u540e\uff0c\u5229\u7528<code>split()<\/code>\u65b9\u6cd5\u5c06\u5176\u8f6c\u6362\u4e3a\u5217\u8868\uff0c\u6700\u540e\u4f7f\u7528\u5217\u8868\u89e3\u6790\u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u6570\u5b57\u3002\u4f8b\u5982\uff1a  <\/p>\n<pre><code class=\"language-python\">numbers = list(map(int, input(&quot;\u8bf7\u8f93\u5165\u591a\u4e2a\u6570\u5b57\uff0c\u7528\u7a7a\u683c\u5206\u9694\uff1a&quot;).split()))\n<\/code><\/pre>\n<p>\u8fd9\u6837\uff0c\u60a8\u5c31\u53ef\u4ee5\u8f7b\u677e\u83b7\u53d6\u7528\u6237\u8f93\u5165\u7684\u591a\u4e2a\u6570\u5b57\u5e76\u5c06\u5176\u5b58\u50a8\u5728\u4e00\u4e2a\u5217\u8868\u4e2d\u3002<\/p>\n<p><strong>\u5728Python\u4e2d\uff0c\u5982\u4f55\u5904\u7406\u7528\u6237\u8f93\u5165\u7684\u975e\u6570\u5b57\u5b57\u7b26\uff1f<\/strong><br \/>\u4e3a\u4e86\u786e\u4fdd\u7528\u6237\u8f93\u5165\u7684\u6709\u6548\u6027\uff0c\u53ef\u4ee5\u4f7f\u7528<code>try<\/code>\u548c<code>except<\/code>\u8bed\u53e5\u6765\u6355\u83b7\u5f02\u5e38\u3002\u5f53\u7528\u6237\u8f93\u5165\u975e\u6570\u5b57\u5b57\u7b26\u65f6\uff0c\u7a0b\u5e8f\u53ef\u4ee5\u63d0\u793a\u7528\u6237\u91cd\u65b0\u8f93\u5165\u3002\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a  <\/p>\n<pre><code class=\"language-python\">while True:\n    try:\n        numbers = list(map(int, input(&quot;\u8bf7\u8f93\u5165\u591a\u4e2a\u6570\u5b57\uff0c\u7528\u7a7a\u683c\u5206\u9694\uff1a&quot;).split()))\n        break\n    except ValueError:\n        print(&quot;\u8f93\u5165\u65e0\u6548\uff0c\u8bf7\u786e\u4fdd\u53ea\u8f93\u5165\u6570\u5b57\u3002&quot;)\n<\/code><\/pre>\n<p>\u8fd9\u6837\u53ef\u4ee5\u6709\u6548\u5730\u5904\u7406\u9519\u8bef\u8f93\u5165\uff0c\u63d0\u9ad8\u7528\u6237\u4f53\u9a8c\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728Python\u4e2d\u5c06\u8f93\u5165\u7684\u591a\u4e2a\u6570\u5b57\u8fdb\u884c\u7edf\u8ba1\u6216\u8ba1\u7b97\uff1f<\/strong><br \/>\u5728\u83b7\u53d6\u7528\u6237\u8f93\u5165\u7684\u6570\u5b57\u540e\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u591a\u79cd\u65b9\u6cd5\u8fdb\u884c\u7edf\u8ba1\u3002\u4f8b\u5982\uff0c\u8ba1\u7b97\u603b\u548c\u3001\u5e73\u5747\u503c\u6216\u6700\u5927\u503c\u7b49\u3002\u4ee5\u4e0b\u793a\u4f8b\u5c55\u793a\u4e86\u5982\u4f55\u5b9e\u73b0\u8fd9\u4e9b\u529f\u80fd\uff1a  <\/p>\n<pre><code class=\"language-python\">numbers = list(map(int, input(&quot;\u8bf7\u8f93\u5165\u591a\u4e2a\u6570\u5b57\uff0c\u7528\u7a7a\u683c\u5206\u9694\uff1a&quot;).split()))\ntotal = sum(numbers)\naverage = total \/ len(numbers)\nmaximum = max(numbers)\n\nprint(f&quot;\u603b\u548c\uff1a{total}, \u5e73\u5747\u503c\uff1a{average}, \u6700\u5927\u503c\uff1a{maximum}&quot;)\n<\/code><\/pre>\n<p>\u901a\u8fc7\u8fd9\u4e9b\u7b80\u5355\u7684\u64cd\u4f5c\uff0c\u60a8\u53ef\u4ee5\u8f7b\u677e\u5730\u5bf9\u8f93\u5165\u7684\u6570\u5b57\u8fdb\u884c\u5206\u6790\u548c\u5904\u7406\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python\u4e2d\u8f93\u5165\u591a\u4e2a\u6570\u5b57\u6709\u591a\u79cd\u65b9\u6cd5\uff0c\u5305\u62ec\u4f7f\u7528input\u51fd\u6570\u3001\u5faa\u73af\u3001\u5217\u8868\u89e3\u6790\u7b49\uff0c\u5177\u4f53\u65b9\u6cd5\u6709\uff1a\u4f7f\u7528input\u51fd [&hellip;]","protected":false},"author":3,"featured_media":1095377,"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\/1095370"}],"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=1095370"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1095370\/revisions"}],"predecessor-version":[{"id":1095380,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1095370\/revisions\/1095380"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1095377"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1095370"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1095370"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1095370"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}