{"id":1150583,"date":"2025-01-13T17:03:19","date_gmt":"2025-01-13T09:03:19","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1150583.html"},"modified":"2025-01-13T17:03:21","modified_gmt":"2025-01-13T09:03:21","slug":"python%e4%b8%ad%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8input","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1150583.html","title":{"rendered":"python\u4e2d\u5982\u4f55\u4f7f\u7528input"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25181038\/851af39f-6d02-4280-811e-c202651eea65.webp\" alt=\"python\u4e2d\u5982\u4f55\u4f7f\u7528input\" \/><\/p>\n<p><p> <strong>Python\u4e2d\u53ef\u4ee5\u4f7f\u7528input()\u51fd\u6570\u6765\u83b7\u53d6\u7528\u6237\u7684\u8f93\u5165<\/strong>\u3001<strong>input()\u51fd\u6570\u4f1a\u6682\u505c\u7a0b\u5e8f\u7684\u6267\u884c\uff0c\u7b49\u5f85\u7528\u6237\u8f93\u5165\uff0c\u7136\u540e\u8fd4\u56de\u8f93\u5165\u7684\u5b57\u7b26\u4e32<\/strong>\u3001<strong>\u53ef\u4ee5\u5c06\u7528\u6237\u7684\u8f93\u5165\u5b58\u50a8\u5728\u53d8\u91cf\u4e2d\u8fdb\u884c\u8fdb\u4e00\u6b65\u5904\u7406<\/strong>\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff0c\u8be6\u7ec6\u4ecb\u7ecd\u4e86\u5982\u4f55\u4f7f\u7528input()\u51fd\u6570\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">user_input = input(&quot;\u8bf7\u8f93\u5165\u4e00\u4e9b\u6587\u672c\uff1a&quot;)<\/p>\n<p>print(&quot;\u4f60\u8f93\u5165\u7684\u662f\uff1a&quot;, user_input)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u8ff0\u793a\u4f8b\u4e2d\uff0c<strong>\u7a0b\u5e8f\u4f1a\u6253\u5370\u201c\u8bf7\u8f93\u5165\u4e00\u4e9b\u6587\u672c\uff1a\u201d\uff0c\u7136\u540e\u7b49\u5f85\u7528\u6237\u8f93\u5165\uff0c\u5f53\u7528\u6237\u8f93\u5165\u4e4b\u540e\uff0c\u7a0b\u5e8f\u4f1a\u5c06\u8f93\u5165\u7684\u5b57\u7b26\u4e32\u5b58\u50a8\u5728\u53d8\u91cfuser_input\u4e2d\uff0c\u5e76\u6253\u5370\u51fa\u6765<\/strong>\u3002\u8fd9\u4e00\u8fc7\u7a0b\u975e\u5e38\u9002\u7528\u4e8e\u9700\u8981\u4e0e\u7528\u6237\u4ea4\u4e92\u7684\u7a0b\u5e8f\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u83b7\u53d6\u7528\u6237\u8f93\u5165<\/h3>\n<\/p>\n<p><p>\u5728Python\u4e2d\uff0c\u83b7\u53d6\u7528\u6237\u8f93\u5165\u6700\u5e38\u89c1\u7684\u65b9\u6cd5\u662f\u4f7f\u7528<code>input()<\/code>\u51fd\u6570\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u57fa\u672c\u7528\u6cd5\uff1a<\/p>\n<\/p>\n<p><h4>1.1 \u57fa\u672c\u7528\u6cd5<\/h4>\n<\/p>\n<p><p>\u5728\u6700\u7b80\u5355\u7684\u5f62\u5f0f\u4e0b\uff0c<code>input()<\/code>\u51fd\u6570\u4f1a\u6682\u505c\u7a0b\u5e8f\u7684\u6267\u884c\uff0c\u76f4\u5230\u7528\u6237\u8f93\u5165\u4e00\u4e9b\u5185\u5bb9\u5e76\u6309\u4e0b\u56de\u8f66\u952e\u3002\u7136\u540e\uff0c\u5b83\u4f1a\u5c06\u7528\u6237\u8f93\u5165\u7684\u5185\u5bb9\u4f5c\u4e3a\u5b57\u7b26\u4e32\u8fd4\u56de\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">name = input(&quot;\u8bf7\u8f93\u5165\u4f60\u7684\u540d\u5b57: &quot;)<\/p>\n<p>print(f&quot;\u4f60\u597d, {name}!&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u7a0b\u5e8f\u4f1a\u6253\u5370\u63d0\u793a\u4fe1\u606f\u201c\u8bf7\u8f93\u5165\u4f60\u7684\u540d\u5b57:\u201d\uff0c\u7136\u540e\u7b49\u5f85\u7528\u6237\u8f93\u5165\u3002\u5f53\u7528\u6237\u8f93\u5165\u4ed6\u4eec\u7684\u540d\u5b57\u5e76\u6309\u4e0b\u56de\u8f66\u952e\u65f6\uff0c\u7a0b\u5e8f\u4f1a\u7ee7\u7eed\u6267\u884c\u5e76\u6253\u5370\u201c\u4f60\u597d, [\u7528\u6237\u8f93\u5165\u7684\u540d\u5b57]\u201d\u3002<\/p>\n<\/p>\n<p><h4>1.2 \u5c06\u8f93\u5165\u8f6c\u6362\u4e3a\u5176\u4ed6\u7c7b\u578b<\/h4>\n<\/p>\n<p><p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<code>input()<\/code>\u51fd\u6570\u8fd4\u56de\u4e00\u4e2a\u5b57\u7b26\u4e32\u3002\u5982\u679c\u4f60\u9700\u8981\u5c06\u7528\u6237\u7684\u8f93\u5165\u8f6c\u6362\u4e3a\u5176\u4ed6\u7c7b\u578b\uff08\u4f8b\u5982\u6574\u6570\u6216\u6d6e\u70b9\u6570\uff09\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u76f8\u5e94\u7684\u7c7b\u578b\u8f6c\u6362\u51fd\u6570\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">age = int(input(&quot;\u8bf7\u8f93\u5165\u4f60\u7684\u5e74\u9f84: &quot;))<\/p>\n<p>height = float(input(&quot;\u8bf7\u8f93\u5165\u4f60\u7684\u8eab\u9ad8\uff08\u7c73\uff09: &quot;))<\/p>\n<p>print(f&quot;\u5e74\u9f84: {age}, \u8eab\u9ad8: {height}\u7c73&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u7528\u6237\u8f93\u5165\u7684\u5e74\u9f84\u88ab\u8f6c\u6362\u4e3a\u6574\u6570\uff0c\u8eab\u9ad8\u88ab\u8f6c\u6362\u4e3a\u6d6e\u70b9\u6570\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u5904\u7406\u8f93\u5165\u9519\u8bef<\/h3>\n<\/p>\n<p><p>\u5728\u5904\u7406\u7528\u6237\u8f93\u5165\u65f6\uff0c\u5e38\u5e38\u9700\u8981\u8003\u8651\u7528\u6237\u53ef\u80fd\u8f93\u5165\u65e0\u6548\u6570\u636e\u7684\u60c5\u51b5\u3002\u4e3a\u4e86\u907f\u514d\u7a0b\u5e8f\u56e0\u4e3a\u65e0\u6548\u8f93\u5165\u800c\u5d29\u6e83\uff0c\u53ef\u4ee5\u4f7f\u7528\u5f02\u5e38\u5904\u7406\u673a\u5236\u6765\u6355\u83b7\u548c\u5904\u7406\u8f93\u5165\u9519\u8bef\u3002<\/p>\n<\/p>\n<p><h4>2.1 \u4f7f\u7528try-except\u5757<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">while True:<\/p>\n<p>    try:<\/p>\n<p>        age = int(input(&quot;\u8bf7\u8f93\u5165\u4f60\u7684\u5e74\u9f84: &quot;))<\/p>\n<p>        break<\/p>\n<p>    except ValueError:<\/p>\n<p>        print(&quot;\u8f93\u5165\u65e0\u6548\uff0c\u8bf7\u8f93\u5165\u4e00\u4e2a\u6574\u6570\u3002&quot;)<\/p>\n<p>print(f&quot;\u5e74\u9f84: {age}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u5982\u679c\u7528\u6237\u8f93\u5165\u7684\u4e0d\u662f\u4e00\u4e2a\u6574\u6570\uff0c<code>int()<\/code>\u51fd\u6570\u4f1a\u5f15\u53d1<code>ValueError<\/code>\u5f02\u5e38\u3002\u7a0b\u5e8f\u4f1a\u6355\u83b7\u8fd9\u4e2a\u5f02\u5e38\u5e76\u63d0\u793a\u7528\u6237\u91cd\u65b0\u8f93\u5165\u3002<\/p>\n<\/p>\n<p><h4>2.2 \u63d0\u793a\u7528\u6237\u8f93\u5165\u6b63\u786e\u683c\u5f0f<\/h4>\n<\/p>\n<p><p>\u4e3a\u4e86\u63d0\u9ad8\u7528\u6237\u4f53\u9a8c\uff0c\u53ef\u4ee5\u7ed9\u51fa\u66f4\u52a0\u5177\u4f53\u7684\u63d0\u793a\u4fe1\u606f\uff0c\u5e2e\u52a9\u7528\u6237\u8f93\u5165\u6b63\u786e\u7684\u683c\u5f0f\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">while True:<\/p>\n<p>    try:<\/p>\n<p>        height = float(input(&quot;\u8bf7\u8f93\u5165\u4f60\u7684\u8eab\u9ad8\uff08\u7c73\uff09\uff0c\u4f8b\u59821.75: &quot;))<\/p>\n<p>        break<\/p>\n<p>    except ValueError:<\/p>\n<p>        print(&quot;\u8f93\u5165\u65e0\u6548\uff0c\u8bf7\u8f93\u5165\u4e00\u4e2a\u6d6e\u70b9\u6570\uff0c\u4f8b\u59821.75\u3002&quot;)<\/p>\n<p>print(f&quot;\u8eab\u9ad8: {height}\u7c73&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u63d0\u793a\u4fe1\u606f\u660e\u786e\u8bf4\u660e\u4e86\u7528\u6237\u5e94\u8be5\u8f93\u5165\u7684\u683c\u5f0f\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u5904\u7406\u591a\u884c\u8f93\u5165<\/h3>\n<\/p>\n<p><p>\u6709\u65f6\uff0c\u53ef\u80fd\u9700\u8981\u7528\u6237\u8f93\u5165\u591a\u884c\u6587\u672c\u3002\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e2a\u5faa\u73af\u6765\u5b9e\u73b0\u8fd9\u4e00\u70b9\uff0c\u76f4\u5230\u7528\u6237\u8f93\u5165\u7279\u5b9a\u7684\u7ed3\u675f\u6807\u5fd7\u3002<\/p>\n<\/p>\n<p><h4>3.1 \u7b80\u5355\u7684\u591a\u884c\u8f93\u5165<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">print(&quot;\u8bf7\u8f93\u5165\u591a\u884c\u6587\u672c\uff08\u8f93\u5165&#39;END&#39;\u7ed3\u675f\uff09\uff1a&quot;)<\/p>\n<p>lines = []<\/p>\n<p>while True:<\/p>\n<p>    line = input()<\/p>\n<p>    if line == &#39;END&#39;:<\/p>\n<p>        break<\/p>\n<p>    lines.append(line)<\/p>\n<p>print(&quot;\u4f60\u8f93\u5165\u7684\u6587\u672c\u662f\uff1a&quot;)<\/p>\n<p>for line in lines:<\/p>\n<p>    print(line)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u7528\u6237\u53ef\u4ee5\u8f93\u5165\u591a\u884c\u6587\u672c\uff0c\u76f4\u5230\u8f93\u5165\u201cEND\u201d\u4e3a\u6b62\u3002\u6240\u6709\u8f93\u5165\u7684\u884c\u4f1a\u88ab\u5b58\u50a8\u5728\u4e00\u4e2a\u5217\u8868\u4e2d\uff0c\u6700\u540e\u6253\u5370\u51fa\u6765\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u63d0\u9ad8\u8f93\u5165\u7684\u7528\u6237\u4f53\u9a8c<\/h3>\n<\/p>\n<p><p>\u4e3a\u4e86\u63d0\u9ad8\u7528\u6237\u8f93\u5165\u7684\u4f53\u9a8c\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e9b\u6280\u672f\u6765\u589e\u5f3a\u8f93\u5165\u7684\u4ea4\u4e92\u6027\u548c\u53ef\u7528\u6027\u3002<\/p>\n<\/p>\n<p><h4>4.1 \u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u9a8c\u8bc1\u8f93\u5165<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u6765\u9a8c\u8bc1\u7528\u6237\u8f93\u5165\u662f\u5426\u7b26\u5408\u9884\u671f\u7684\u683c\u5f0f\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import re<\/p>\n<p>em<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>l_pattern = r&#39;^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+$&#39;<\/p>\n<p>while True:<\/p>\n<p>    email = input(&quot;\u8bf7\u8f93\u5165\u4f60\u7684\u7535\u5b50\u90ae\u4ef6\u5730\u5740: &quot;)<\/p>\n<p>    if re.match(email_pattern, email):<\/p>\n<p>        break<\/p>\n<p>    else:<\/p>\n<p>        print(&quot;\u8f93\u5165\u65e0\u6548\uff0c\u8bf7\u8f93\u5165\u4e00\u4e2a\u6709\u6548\u7684\u7535\u5b50\u90ae\u4ef6\u5730\u5740\u3002&quot;)<\/p>\n<p>print(f&quot;\u7535\u5b50\u90ae\u4ef6\u5730\u5740: {email}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u6765\u9a8c\u8bc1\u7528\u6237\u8f93\u5165\u7684\u7535\u5b50\u90ae\u4ef6\u5730\u5740\u662f\u5426\u6709\u6548\u3002<\/p>\n<\/p>\n<p><h4>4.2 \u4f7f\u7528\u9ed8\u8ba4\u503c<\/h4>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u7528\u6237\u53ef\u80fd\u5e0c\u671b\u4f7f\u7528\u9ed8\u8ba4\u503c\u3002\u4f60\u53ef\u4ee5\u63d0\u4f9b\u4e00\u4e2a\u9ed8\u8ba4\u503c\uff0c\u5e76\u5141\u8bb8\u7528\u6237\u76f4\u63a5\u6309\u56de\u8f66\u952e\u6765\u63a5\u53d7\u5b83\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">default_name = &quot;\u533f\u540d&quot;<\/p>\n<p>name = input(f&quot;\u8bf7\u8f93\u5165\u4f60\u7684\u540d\u5b57\uff08\u9ed8\u8ba4: {default_name}\uff09: &quot;) or default_name<\/p>\n<p>print(f&quot;\u4f60\u597d, {name}!&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u5982\u679c\u7528\u6237\u76f4\u63a5\u6309\u56de\u8f66\u952e\uff0c\u7a0b\u5e8f\u4f1a\u4f7f\u7528\u9ed8\u8ba4\u503c\u201c\u533f\u540d\u201d\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001\u5904\u7406\u5bc6\u7801\u8f93\u5165<\/h3>\n<\/p>\n<p><p>\u5728\u5904\u7406\u654f\u611f\u4fe1\u606f\uff08\u5982\u5bc6\u7801\uff09\u65f6\uff0c\u4e0d\u5e0c\u671b\u7528\u6237\u8f93\u5165\u7684\u5185\u5bb9\u663e\u793a\u5728\u5c4f\u5e55\u4e0a\u3002\u53ef\u4ee5\u4f7f\u7528<code>getpass<\/code>\u6a21\u5757\u6765\u5b9e\u73b0\u8fd9\u4e00\u70b9\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import getpass<\/p>\n<p>password = getpass.getpass(&quot;\u8bf7\u8f93\u5165\u4f60\u7684\u5bc6\u7801: &quot;)<\/p>\n<p>print(&quot;\u5bc6\u7801\u8f93\u5165\u6210\u529f\u3002&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u7528\u6237\u8f93\u5165\u7684\u5bc6\u7801\u4e0d\u4f1a\u663e\u793a\u5728\u5c4f\u5e55\u4e0a\u3002<\/p>\n<\/p>\n<p><h3>\u516d\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u901a\u8fc7\u672c\u6587\uff0c\u6211\u4eec\u8be6\u7ec6\u4ecb\u7ecd\u4e86\u5982\u4f55\u5728Python\u4e2d\u4f7f\u7528<code>input()<\/code>\u51fd\u6570\u83b7\u53d6\u7528\u6237\u8f93\u5165\uff0c\u5e76\u8ba8\u8bba\u4e86\u5904\u7406\u8f93\u5165\u9519\u8bef\u3001\u591a\u884c\u8f93\u5165\u3001\u63d0\u9ad8\u7528\u6237\u4f53\u9a8c\u4ee5\u53ca\u5904\u7406\u5bc6\u7801\u8f93\u5165\u7684\u65b9\u6cd5\u3002<strong>\u638c\u63e1\u8fd9\u4e9b\u6280\u5de7\u53ef\u4ee5\u5e2e\u52a9\u4f60\u7f16\u5199\u66f4\u52a0\u5065\u58ee\u548c\u7528\u6237\u53cb\u597d\u7684\u4ea4\u4e92\u5f0f\u7a0b\u5e8f<\/strong>\u3002\u5e0c\u671b\u8fd9\u4e9b\u5185\u5bb9\u5bf9\u4f60\u5728Python\u7f16\u7a0b\u8fc7\u7a0b\u4e2d\u6709\u6240\u5e2e\u52a9\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u83b7\u53d6\u7528\u6237\u8f93\u5165\u7684\u503c\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u4f7f\u7528<code>input()<\/code>\u51fd\u6570\u53ef\u4ee5\u8f7b\u677e\u83b7\u53d6\u7528\u6237\u8f93\u5165\u3002\u8fd9\u4e2a\u51fd\u6570\u4f1a\u6682\u505c\u7a0b\u5e8f\u7684\u6267\u884c\uff0c\u76f4\u5230\u7528\u6237\u8f93\u5165\u5185\u5bb9\u5e76\u6309\u4e0b\u56de\u8f66\u952e\u3002\u8f93\u5165\u7684\u5185\u5bb9\u5c06\u4f5c\u4e3a\u5b57\u7b26\u4e32\u8fd4\u56de\u3002\u4f8b\u5982\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u83b7\u53d6\u7528\u6237\u7684\u540d\u5b57\u5e76\u8f93\u51fa\u6b22\u8fce\u4fe1\u606f\uff1a<\/p>\n<pre><code class=\"language-python\">name = input(&quot;\u8bf7\u8f93\u5165\u60a8\u7684\u540d\u5b57\uff1a&quot;)\nprint(f&quot;\u6b22\u8fce\uff0c{name}\uff01&quot;)\n<\/code><\/pre>\n<p><strong>input\u51fd\u6570\u652f\u6301\u54ea\u4e9b\u53c2\u6570\uff1f<\/strong><br \/><code>input()<\/code>\u51fd\u6570\u53ef\u4ee5\u63a5\u6536\u4e00\u4e2a\u53ef\u9009\u7684\u5b57\u7b26\u4e32\u53c2\u6570\uff0c\u8fd9\u4e2a\u53c2\u6570\u7528\u4e8e\u63d0\u793a\u7528\u6237\u8f93\u5165\u5185\u5bb9\u3002\u4f8b\u5982\uff0c\u60a8\u53ef\u4ee5\u8fd9\u6837\u4f7f\u7528\uff1a<\/p>\n<pre><code class=\"language-python\">age = input(&quot;\u8bf7\u8f93\u5165\u60a8\u7684\u5e74\u9f84\uff1a&quot;)\n<\/code><\/pre>\n<p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c&quot;\u8bf7\u8f93\u5165\u60a8\u7684\u5e74\u9f84\uff1a&quot;\u5c06\u4f5c\u4e3a\u63d0\u793a\u4fe1\u606f\u663e\u793a\u7ed9\u7528\u6237\uff0c\u5e2e\u52a9\u4ed6\u4eec\u77e5\u9053\u9700\u8981\u8f93\u5165\u4ec0\u4e48\u3002<\/p>\n<p><strong>\u5982\u4f55\u5904\u7406\u7528\u6237\u8f93\u5165\u7684\u7c7b\u578b\u8f6c\u6362\uff1f<\/strong><br \/>\u7528\u6237\u901a\u8fc7<code>input()<\/code>\u51fd\u6570\u8f93\u5165\u7684\u6240\u6709\u5185\u5bb9\u90fd\u88ab\u89c6\u4e3a\u5b57\u7b26\u4e32\u3002\u5982\u679c\u60a8\u9700\u8981\u5c06\u8f93\u5165\u8f6c\u6362\u4e3a\u5176\u4ed6\u7c7b\u578b\uff0c\u6bd4\u5982\u6574\u6570\u6216\u6d6e\u70b9\u6570\uff0c\u53ef\u4ee5\u4f7f\u7528\u76f8\u5e94\u7684\u7c7b\u578b\u8f6c\u6362\u51fd\u6570\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff1a<\/p>\n<pre><code class=\"language-python\">age = int(input(&quot;\u8bf7\u8f93\u5165\u60a8\u7684\u5e74\u9f84\uff1a&quot;))\nprint(f&quot;\u60a8\u8f93\u5165\u7684\u5e74\u9f84\u662f\uff1a{age}\u5c81&quot;)\n<\/code><\/pre>\n<p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u8f93\u5165\u7684\u5e74\u9f84\u5b57\u7b26\u4e32\u88ab\u8f6c\u6362\u4e3a\u6574\u6570\u7c7b\u578b\uff0c\u4ee5\u4fbf\u8fdb\u884c\u8fdb\u4e00\u6b65\u7684\u6570\u5b66\u8fd0\u7b97\u6216\u903b\u8f91\u5224\u65ad\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Python\u4e2d\u53ef\u4ee5\u4f7f\u7528input()\u51fd\u6570\u6765\u83b7\u53d6\u7528\u6237\u7684\u8f93\u5165\u3001input()\u51fd\u6570\u4f1a\u6682\u505c\u7a0b\u5e8f\u7684\u6267\u884c\uff0c\u7b49\u5f85\u7528\u6237\u8f93\u5165\uff0c\u7136 [&hellip;]","protected":false},"author":3,"featured_media":1150590,"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\/1150583"}],"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=1150583"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1150583\/revisions"}],"predecessor-version":[{"id":1150591,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1150583\/revisions\/1150591"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1150590"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1150583"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1150583"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1150583"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}