{"id":1181679,"date":"2025-01-15T18:54:41","date_gmt":"2025-01-15T10:54:41","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1181679.html"},"modified":"2025-01-15T18:54:43","modified_gmt":"2025-01-15T10:54:43","slug":"python%e5%a6%82%e4%bd%95%e7%9b%b4%e6%8e%a5%e8%be%93%e5%85%a5%e8%be%93%e5%87%ba","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1181679.html","title":{"rendered":"python\u5982\u4f55\u76f4\u63a5\u8f93\u5165\u8f93\u51fa"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25125931\/52d757a5-843a-4ee0-8ec8-4cc92ae6da54.webp\" alt=\"python\u5982\u4f55\u76f4\u63a5\u8f93\u5165\u8f93\u51fa\" \/><\/p>\n<p><p> <strong>\u76f4\u63a5\u8f93\u5165\u8f93\u51faPython\u6709\u591a\u79cd\u65b9\u6cd5<\/strong>\uff0c\u5982\u4f7f\u7528input()\u51fd\u6570\u3001print()\u51fd\u6570\u3001\u6587\u4ef6\u64cd\u4f5c\u3001\u6807\u51c6\u8f93\u5165\u8f93\u51fa\u5e93\u3001GUI\u5e93\u7b49\u3002<strong>\u5e38\u7528\u7684\u65b9\u6cd5\u662f\u4f7f\u7528input()\u548cprint()\u51fd\u6570\u3002<\/strong> \u5176\u4e2d\uff0cprint()\u51fd\u6570\u7528\u4e8e\u5c06\u4fe1\u606f\u8f93\u51fa\u5230\u63a7\u5236\u53f0\uff0cinput()\u51fd\u6570\u7528\u4e8e\u4ece\u63a7\u5236\u53f0\u8bfb\u53d6\u7528\u6237\u8f93\u5165\u3002<strong>\u4f8b\u5982\uff0c\u4f7f\u7528input()\u51fd\u6570\uff0c\u53ef\u4ee5\u63d0\u793a\u7528\u6237\u8f93\u5165\u4ed6\u4eec\u7684\u540d\u5b57\uff0c\u5e76\u4f7f\u7528print()\u51fd\u6570\u5c06\u8f93\u5165\u7684\u540d\u5b57\u8f93\u51fa\u5230\u63a7\u5236\u53f0\u3002<\/strong><\/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(&quot;\u4f60\u597d, &quot; + name + &quot;!&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u6bb5\u4ee3\u7801\u4e2d\uff0cinput()\u51fd\u6570\u7b49\u5f85\u7528\u6237\u5728\u63a7\u5236\u53f0\u8f93\u5165\u4ed6\u4eec\u7684\u540d\u5b57\uff0c\u5e76\u5c06\u8f93\u5165\u7684\u5b57\u7b26\u4e32\u8d4b\u503c\u7ed9\u53d8\u91cfname\u3002\u7136\u540e\uff0cprint()\u51fd\u6570\u8f93\u51fa\u4e00\u6761\u95ee\u5019\u6d88\u606f\uff0c\u5176\u4e2d\u5305\u542b\u7528\u6237\u8f93\u5165\u7684\u540d\u5b57\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001PRINT()\u51fd\u6570<\/h3>\n<\/p>\n<p><p><strong>print()\u51fd\u6570\u662fPython\u4e2d\u6700\u5e38\u7528\u7684\u8f93\u51fa\u51fd\u6570\u3002<\/strong> \u5b83\u53ef\u4ee5\u5c06\u6307\u5b9a\u5185\u5bb9\u8f93\u51fa\u5230\u63a7\u5236\u53f0\u3002print()\u51fd\u6570\u53ef\u4ee5\u63a5\u53d7\u591a\u4e2a\u53c2\u6570\uff0c\u5e76\u5c06\u5b83\u4eec\u4ee5\u7a7a\u683c\u5206\u9694\u7684\u5f62\u5f0f\u8f93\u51fa\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u89c1\u7684\u7528\u6cd5\uff1a<\/p>\n<\/p>\n<p><h4>1.1\u3001\u57fa\u672c\u8f93\u51fa<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">print(&quot;Hello, World!&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u6bb5\u4ee3\u7801\u4e2d\uff0cprint()\u51fd\u6570\u8f93\u51fa\u5b57\u7b26\u4e32\u201cHello, World!\u201d\u5230\u63a7\u5236\u53f0\u3002<\/p>\n<\/p>\n<p><h4>1.2\u3001\u8f93\u51fa\u591a\u4e2a\u503c<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">x = 5<\/p>\n<p>y = 10<\/p>\n<p>print(&quot;x =&quot;, x, &quot;y =&quot;, y)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u6bb5\u4ee3\u7801\u4e2d\uff0cprint()\u51fd\u6570\u8f93\u51fa\u591a\u4e2a\u503c\uff0c\u4e2d\u95f4\u7528\u7a7a\u683c\u5206\u9694\u3002<\/p>\n<\/p>\n<p><h4>1.3\u3001\u683c\u5f0f\u5316\u8f93\u51fa<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u4f7f\u7528\u5b57\u7b26\u4e32\u7684format()\u65b9\u6cd5\u6216\u8005f\u5b57\u7b26\u4e32\u6765\u683c\u5f0f\u5316\u8f93\u51fa\u5185\u5bb9\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u4f7f\u7528format()\u65b9\u6cd5<\/p>\n<p>name = &quot;Alice&quot;<\/p>\n<p>age = 25<\/p>\n<p>print(&quot;Name: {}, Age: {}&quot;.format(name, age))<\/p>\n<h2><strong>\u4f7f\u7528f\u5b57\u7b26\u4e32<\/strong><\/h2>\n<p>print(f&quot;Name: {name}, Age: {age}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u6bb5\u4ee3\u7801\u4e2d\uff0cformat()\u65b9\u6cd5\u548cf\u5b57\u7b26\u4e32\u7528\u4e8e\u5c06\u53d8\u91cf\u7684\u503c\u63d2\u5165\u5230\u5b57\u7b26\u4e32\u4e2d\uff0c\u5f62\u6210\u683c\u5f0f\u5316\u8f93\u51fa\u3002<\/p>\n<\/p>\n<p><h4>1.4\u3001\u81ea\u5b9a\u4e49\u5206\u9694\u7b26\u548c\u7ed3\u675f\u7b26<\/h4>\n<\/p>\n<p><p>print()\u51fd\u6570\u53ef\u4ee5\u901a\u8fc7sep\u53c2\u6570\u548cend\u53c2\u6570\u81ea\u5b9a\u4e49\u8f93\u51fa\u7684\u5206\u9694\u7b26\u548c\u7ed3\u675f\u7b26\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u81ea\u5b9a\u4e49\u5206\u9694\u7b26<\/p>\n<p>print(&quot;apple&quot;, &quot;banana&quot;, &quot;cherry&quot;, sep=&quot;, &quot;)<\/p>\n<h2><strong>\u81ea\u5b9a\u4e49\u7ed3\u675f\u7b26<\/strong><\/h2>\n<p>print(&quot;Hello&quot;, end=&quot; &quot;)<\/p>\n<p>print(&quot;World&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u6bb5\u4ee3\u7801\u4e2d\uff0csep\u53c2\u6570\u5c06\u8f93\u51fa\u7684\u591a\u4e2a\u503c\u7528\u9017\u53f7\u548c\u7a7a\u683c\u5206\u9694\uff0cend\u53c2\u6570\u5c06\u8f93\u51fa\u7684\u7ed3\u675f\u7b26\u6539\u4e3a\u4e00\u4e2a\u7a7a\u683c\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001INPUT()\u51fd\u6570<\/h3>\n<\/p>\n<p><p><strong>input()\u51fd\u6570\u7528\u4e8e\u4ece\u63a7\u5236\u53f0\u8bfb\u53d6\u7528\u6237\u8f93\u5165\u3002<\/strong> \u5b83\u4f1a\u6682\u505c\u7a0b\u5e8f\u7684\u6267\u884c\uff0c\u7b49\u5f85\u7528\u6237\u8f93\u5165\uff0c\u5e76\u8fd4\u56de\u8f93\u5165\u7684\u5b57\u7b26\u4e32\u3002<\/p>\n<\/p>\n<p><h4>2.1\u3001\u57fa\u672c\u8f93\u5165<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">name = input(&quot;\u8bf7\u8f93\u5165\u4f60\u7684\u540d\u5b57: &quot;)<\/p>\n<p>print(&quot;\u4f60\u597d, &quot; + name + &quot;!&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u6bb5\u4ee3\u7801\u4e2d\uff0cinput()\u51fd\u6570\u7b49\u5f85\u7528\u6237\u8f93\u5165\u4ed6\u4eec\u7684\u540d\u5b57\uff0c\u5e76\u5c06\u8f93\u5165\u7684\u5b57\u7b26\u4e32\u8d4b\u503c\u7ed9\u53d8\u91cfname\u3002\u7136\u540e\uff0cprint()\u51fd\u6570\u8f93\u51fa\u4e00\u6761\u95ee\u5019\u6d88\u606f\uff0c\u5176\u4e2d\u5305\u542b\u7528\u6237\u8f93\u5165\u7684\u540d\u5b57\u3002<\/p>\n<\/p>\n<p><h4>2.2\u3001\u8bfb\u53d6\u6570\u5b57\u8f93\u5165<\/h4>\n<\/p>\n<p><p>\u7531\u4e8einput()\u51fd\u6570\u8fd4\u56de\u7684\u662f\u5b57\u7b26\u4e32\uff0c\u6240\u4ee5\u5982\u679c\u9700\u8981\u8bfb\u53d6\u6570\u5b57\u8f93\u5165\uff0c\u53ef\u4ee5\u4f7f\u7528int()\u6216float()\u51fd\u6570\u5c06\u8f93\u5165\u7684\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u6574\u6570\u6216\u6d6e\u70b9\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>print(&quot;\u4f60\u660e\u5e74\u5c06\u4f1a&quot;, age + 1, &quot;\u5c81&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u6bb5\u4ee3\u7801\u4e2d\uff0cint()\u51fd\u6570\u5c06\u7528\u6237\u8f93\u5165\u7684\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u6574\u6570\uff0c\u7136\u540eprint()\u51fd\u6570\u8f93\u51fa\u7528\u6237\u660e\u5e74\u7684\u5e74\u9f84\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u6587\u4ef6\u64cd\u4f5c<\/h3>\n<\/p>\n<p><p><strong>\u9664\u4e86\u63a7\u5236\u53f0\u8f93\u5165\u8f93\u51fa\uff0cPython\u8fd8\u652f\u6301\u6587\u4ef6\u64cd\u4f5c\u3002<\/strong> \u53ef\u4ee5\u4f7f\u7528open()\u51fd\u6570\u6253\u5f00\u6587\u4ef6\uff0c\u4f7f\u7528read()\u548cwrite()\u65b9\u6cd5\u8bfb\u53d6\u548c\u5199\u5165\u6587\u4ef6\u5185\u5bb9\u3002<\/p>\n<\/p>\n<p><h4>3.1\u3001\u8bfb\u53d6\u6587\u4ef6\u5185\u5bb9<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">with open(&quot;example.txt&quot;, &quot;r&quot;) as file:<\/p>\n<p>    content = file.read()<\/p>\n<p>    print(content)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u6bb5\u4ee3\u7801\u4e2d\uff0copen()\u51fd\u6570\u4ee5\u53ea\u8bfb\u6a21\u5f0f\u6253\u5f00\u540d\u4e3a\u201cexample.txt\u201d\u7684\u6587\u4ef6\uff0c\u5e76\u8fd4\u56de\u4e00\u4e2a\u6587\u4ef6\u5bf9\u8c61\u3002with\u8bed\u53e5\u786e\u4fdd\u5728\u4ee3\u7801\u5757\u6267\u884c\u5b8c\u6bd5\u540e\u81ea\u52a8\u5173\u95ed\u6587\u4ef6\u3002read()\u65b9\u6cd5\u8bfb\u53d6\u6587\u4ef6\u7684\u5168\u90e8\u5185\u5bb9\uff0c\u5e76\u5c06\u5176\u8f93\u51fa\u5230\u63a7\u5236\u53f0\u3002<\/p>\n<\/p>\n<p><h4>3.2\u3001\u5199\u5165\u6587\u4ef6\u5185\u5bb9<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">with open(&quot;example.txt&quot;, &quot;w&quot;) as file:<\/p>\n<p>    file.write(&quot;Hello, World!&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u6bb5\u4ee3\u7801\u4e2d\uff0copen()\u51fd\u6570\u4ee5\u5199\u5165\u6a21\u5f0f\u6253\u5f00\u540d\u4e3a\u201cexample.txt\u201d\u7684\u6587\u4ef6\uff0c\u5982\u679c\u6587\u4ef6\u4e0d\u5b58\u5728\u5219\u521b\u5efa\u6587\u4ef6\u3002write()\u65b9\u6cd5\u5c06\u5b57\u7b26\u4e32\u201cHello, World!\u201d\u5199\u5165\u5230\u6587\u4ef6\u4e2d\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u6807\u51c6\u8f93\u5165\u8f93\u51fa\u5e93<\/h3>\n<\/p>\n<p><p><strong>Python\u63d0\u4f9b\u4e86sys\u6a21\u5757\uff0c\u53ef\u4ee5\u66f4\u7075\u6d3b\u5730\u5904\u7406\u6807\u51c6\u8f93\u5165\u8f93\u51fa\u3002<\/strong> sys.stdin\u7528\u4e8e\u6807\u51c6\u8f93\u5165\uff0csys.stdout\u7528\u4e8e\u6807\u51c6\u8f93\u51fa\uff0csys.stderr\u7528\u4e8e\u6807\u51c6\u9519\u8bef\u8f93\u51fa\u3002<\/p>\n<\/p>\n<p><h4>4.1\u3001\u4ece\u6807\u51c6\u8f93\u5165\u8bfb\u53d6<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">import sys<\/p>\n<p>for line in sys.stdin:<\/p>\n<p>    print(line.strip())<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u6bb5\u4ee3\u7801\u4e2d\uff0c\u4ece\u6807\u51c6\u8f93\u5165\u8bfb\u53d6\u6bcf\u4e00\u884c\uff0c\u5e76\u4f7f\u7528print()\u51fd\u6570\u5c06\u5176\u8f93\u51fa\u5230\u63a7\u5236\u53f0\u3002strip()\u65b9\u6cd5\u7528\u4e8e\u53bb\u9664\u884c\u672b\u7684\u6362\u884c\u7b26\u3002<\/p>\n<\/p>\n<p><h4>4.2\u3001\u91cd\u5b9a\u5411\u6807\u51c6\u8f93\u51fa<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">import sys<\/p>\n<p>with open(&quot;output.txt&quot;, &quot;w&quot;) as file:<\/p>\n<p>    sys.stdout = file<\/p>\n<p>    print(&quot;This will be written to the file&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u6bb5\u4ee3\u7801\u4e2d\uff0csys.stdout\u88ab\u91cd\u5b9a\u5411\u5230\u4e00\u4e2a\u6587\u4ef6\u5bf9\u8c61\uff0c\u4f7f\u5f97print()\u51fd\u6570\u7684\u8f93\u51fa\u88ab\u5199\u5165\u5230\u6587\u4ef6\u201coutput.txt\u201d\u4e2d\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001GUI\u5e93<\/h3>\n<\/p>\n<p><p><strong>Python\u8fd8\u652f\u6301\u56fe\u5f62\u7528\u6237\u754c\u9762\uff08GUI\uff09\u7684\u8f93\u5165\u8f93\u51fa\u3002<\/strong> \u5e38\u89c1\u7684GUI\u5e93\u5305\u62ecTkinter\u3001PyQt\u3001wxPython\u7b49\u3002<\/p>\n<\/p>\n<p><h4>5.1\u3001\u4f7f\u7528Tkinter\u521b\u5efa\u7b80\u5355\u7684\u8f93\u5165\u8f93\u51fa\u754c\u9762<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">import tkinter as tk<\/p>\n<p>def on_button_click():<\/p>\n<p>    name = entry.get()<\/p>\n<p>    label.config(text=f&quot;Hello, {name}!&quot;)<\/p>\n<p>root = tk.Tk()<\/p>\n<p>root.title(&quot;Simple GUI&quot;)<\/p>\n<p>label = tk.Label(root, text=&quot;Enter your name:&quot;)<\/p>\n<p>label.pack()<\/p>\n<p>entry = tk.Entry(root)<\/p>\n<p>entry.pack()<\/p>\n<p>button = tk.Button(root, text=&quot;Greet&quot;, command=on_button_click)<\/p>\n<p>button.pack()<\/p>\n<p>root.m<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>nloop()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u6bb5\u4ee3\u7801\u4e2d\uff0c\u4f7f\u7528Tkinter\u5e93\u521b\u5efa\u4e86\u4e00\u4e2a\u7b80\u5355\u7684\u8f93\u5165\u8f93\u51fa\u754c\u9762\u3002\u7528\u6237\u53ef\u4ee5\u5728\u6587\u672c\u6846\u4e2d\u8f93\u5165\u540d\u5b57\uff0c\u70b9\u51fb\u6309\u94ae\u540e\uff0c\u6807\u7b7e\u663e\u793a\u4e00\u6761\u95ee\u5019\u6d88\u606f\u3002<\/p>\n<\/p>\n<p><p>\u901a\u8fc7\u4e0a\u8ff0\u591a\u79cd\u65b9\u6cd5\uff0cPython\u53ef\u4ee5\u5b9e\u73b0\u7075\u6d3b\u591a\u6837\u7684\u8f93\u5165\u8f93\u51fa\u64cd\u4f5c\uff0c\u6ee1\u8db3\u4e0d\u540c\u573a\u666f\u7684\u9700\u6c42\u3002\u65e0\u8bba\u662f\u7b80\u5355\u7684\u63a7\u5236\u53f0\u5e94\u7528\u8fd8\u662f\u590d\u6742\u7684\u56fe\u5f62\u754c\u9762\u5e94\u7528\uff0cPython\u90fd\u80fd\u63d0\u4f9b\u76f8\u5e94\u7684\u89e3\u51b3\u65b9\u6848\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u5b9e\u73b0\u7528\u6237\u8f93\u5165\u548c\u8f93\u51fa\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528<code>input()<\/code>\u51fd\u6570\u63a5\u6536\u7528\u6237\u8f93\u5165\uff0c\u5e76\u4f7f\u7528<code>print()<\/code>\u51fd\u6570\u5c06\u4fe1\u606f\u8f93\u51fa\u5230\u63a7\u5236\u53f0\u3002\u4f8b\u5982\uff0c<code>name = input(&quot;\u8bf7\u8f93\u5165\u60a8\u7684\u540d\u5b57: &quot;)<\/code>\u5c06\u63d0\u793a\u7528\u6237\u8f93\u5165\u540d\u5b57\uff0c\u5e76\u5c06\u8f93\u5165\u7684\u503c\u5b58\u50a8\u5728\u53d8\u91cf<code>name<\/code>\u4e2d\u3002\u968f\u540e\uff0c\u4f7f\u7528<code>print(&quot;\u4f60\u597d\uff0c&quot; + name + &quot;!&quot;)<\/code>\u53ef\u4ee5\u8f93\u51fa\u6b22\u8fce\u4fe1\u606f\u3002<\/p>\n<p><strong>Python\u4e2d\u7684\u8f93\u5165\u8f93\u51fa\u64cd\u4f5c\u6709\u54ea\u4e9b\u5e38\u7528\u6280\u5de7\uff1f<\/strong><br \/>\u9664\u4e86\u57fa\u672c\u7684<code>input()<\/code>\u548c<code>print()<\/code>\uff0cPython\u8fd8\u652f\u6301\u683c\u5f0f\u5316\u8f93\u51fa\uff0c\u4f8b\u5982\u4f7f\u7528f-string\uff08\u683c\u5f0f\u5316\u5b57\u7b26\u4e32\uff09\u6765\u7b80\u5316\u4ee3\u7801\u3002\u53ef\u4ee5\u901a\u8fc7<code>print(f&quot;\u4f60\u597d\uff0c{name}!&quot;)<\/code>\u6765\u5b9e\u73b0\u76f8\u540c\u7684\u6548\u679c\u3002\u6b64\u5916\uff0c<code>input()<\/code>\u51fd\u6570\u4e5f\u652f\u6301\u9ed8\u8ba4\u503c\uff0c\u901a\u8fc7\u5c06\u5176\u5c01\u88c5\u5728try-except\u5757\u4e2d\uff0c\u53ef\u4ee5\u6709\u6548\u5904\u7406\u7528\u6237\u8f93\u5165\u9519\u8bef\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728Python\u4e2d\u5904\u7406\u591a\u884c\u8f93\u5165\u548c\u8f93\u51fa\uff1f<\/strong><br \/>\u5bf9\u4e8e\u9700\u8981\u591a\u884c\u8f93\u5165\u7684\u60c5\u51b5\uff0c\u53ef\u4ee5\u4f7f\u7528\u5faa\u73af\u7ed3\u6784\u3002\u901a\u8fc7<code>while<\/code>\u5faa\u73af\uff0c\u53ef\u4ee5\u4e0d\u65ad\u63a5\u6536\u7528\u6237\u7684\u8f93\u5165\uff0c\u76f4\u5230\u6ee1\u8db3\u7279\u5b9a\u6761\u4ef6\uff08\u5982\u7528\u6237\u8f93\u5165\u201c\u7ed3\u675f\u201d\uff09\u3002\u5bf9\u4e8e\u8f93\u51fa\uff0c\u53ef\u4ee5\u4f7f\u7528\u5217\u8868\u6216\u5b57\u5178\u7b49\u6570\u636e\u7ed3\u6784\u6765\u5b58\u50a8\u4fe1\u606f\uff0c\u6700\u540e\u4f7f\u7528\u5faa\u73af\u904d\u5386\u5e76\u8f93\u51fa\u6240\u6709\u5185\u5bb9\u3002\u8fd9\u6837\u53ef\u4ee5\u6709\u6548\u5730\u7ba1\u7406\u548c\u5c55\u793a\u591a\u884c\u6570\u636e\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u76f4\u63a5\u8f93\u5165\u8f93\u51faPython\u6709\u591a\u79cd\u65b9\u6cd5\uff0c\u5982\u4f7f\u7528input()\u51fd\u6570\u3001print()\u51fd\u6570\u3001\u6587\u4ef6\u64cd\u4f5c\u3001\u6807\u51c6\u8f93\u5165\u8f93\u51fa\u5e93\u3001G [&hellip;]","protected":false},"author":3,"featured_media":1181682,"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\/1181679"}],"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=1181679"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1181679\/revisions"}],"predecessor-version":[{"id":1181683,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1181679\/revisions\/1181683"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1181682"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1181679"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1181679"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1181679"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}