{"id":1014447,"date":"2024-12-27T11:56:18","date_gmt":"2024-12-27T03:56:18","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1014447.html"},"modified":"2024-12-27T11:56:21","modified_gmt":"2024-12-27T03:56:21","slug":"python%e5%a6%82%e4%bd%95%e7%a6%81%e6%ad%a2%e8%be%93%e5%87%ba%e6%8d%a2%e8%a1%8c","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1014447.html","title":{"rendered":"python\u5982\u4f55\u7981\u6b62\u8f93\u51fa\u6362\u884c"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25094551\/e0f2f70d-ec32-4007-a0bc-f3fe621b296c.webp\" alt=\"python\u5982\u4f55\u7981\u6b62\u8f93\u51fa\u6362\u884c\" \/><\/p>\n<p><p> <strong>\u5728Python\u4e2d\uff0c\u7981\u6b62\u8f93\u51fa\u6362\u884c\u53ef\u4ee5\u4f7f\u7528<code>end<\/code>\u53c2\u6570\u3001\u7ed3\u5408\u5b57\u7b26\u4e32\u62fc\u63a5\u3001\u4f7f\u7528<code>sys.stdout.write<\/code>\u65b9\u6cd5\u3002\u8fd9\u4e9b\u65b9\u6cd5\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u5728\u6253\u5370\u8f93\u51fa\u65f6\u66f4\u597d\u5730\u63a7\u5236\u683c\u5f0f\uff0c\u5c24\u5176\u662f\u5728\u9700\u8981\u8fde\u7eed\u6253\u5370\u591a\u884c\u6570\u636e\u800c\u4e0d\u81ea\u52a8\u6362\u884c\u65f6\u3002<\/strong> \u8be6\u7ec6\u6765\u8bf4\uff0c<code>print()<\/code>\u51fd\u6570\u4e2d\u7684<code>end<\/code>\u53c2\u6570\u53ef\u4ee5\u6539\u53d8\u8f93\u51fa\u7ed3\u675f\u65f6\u7684\u9ed8\u8ba4\u884c\u4e3a\uff0c\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c<code>print()<\/code>\u51fd\u6570\u5728\u8f93\u51fa\u540e\u4f1a\u81ea\u52a8\u6dfb\u52a0\u4e00\u4e2a\u6362\u884c\u7b26\uff0c\u4f46\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u6307\u5b9a<code>end<\/code>\u53c2\u6570\u7684\u503c\u6765\u6539\u53d8\u8fd9\u4e00\u884c\u4e3a\u3002<\/p>\n<\/p>\n<p><p>\u5728Python\u4e2d\uff0c<code>print()<\/code>\u51fd\u6570\u662f\u6700\u5e38\u7528\u7684\u8f93\u51fa\u65b9\u6cd5\u4e4b\u4e00\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<code>print()<\/code>\u5728\u6bcf\u6b21\u8f93\u51fa\u540e\u4f1a\u81ea\u52a8\u6dfb\u52a0\u4e00\u4e2a\u6362\u884c\u7b26\u3002\u7136\u800c\uff0c\u6709\u65f6\u5019\u6211\u4eec\u9700\u8981\u5728\u540c\u4e00\u884c\u8fde\u7eed\u6253\u5370\u591a\u4e2a\u5185\u5bb9\uff0c\u800c\u4e0d\u5e0c\u671b\u8f93\u51fa\u81ea\u52a8\u6362\u884c\u3002\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0cPython\u63d0\u4f9b\u4e86\u591a\u4e2a\u65b9\u6cd5\u6765\u63a7\u5236\u8f93\u51fa\u683c\u5f0f\uff0c\u5176\u4e2d\u6700\u7b80\u5355\u7684\u65b9\u6cd5\u5c31\u662f\u5229\u7528<code>print()<\/code>\u51fd\u6570\u7684<code>end<\/code>\u53c2\u6570\u3002\u6b64\u5916\uff0c\u8fd8\u53ef\u4ee5\u901a\u8fc7\u5b57\u7b26\u4e32\u62fc\u63a5\u548c<code>sys.stdout.write<\/code>\u65b9\u6cd5\u5b9e\u73b0\u66f4\u7cbe\u7ec6\u7684\u8f93\u51fa\u63a7\u5236\u3002\u5728\u63a5\u4e0b\u6765\u7684\u90e8\u5206\u4e2d\uff0c\u6211\u4eec\u5c06\u8be6\u7ec6\u8ba8\u8bba\u8fd9\u4e9b\u65b9\u6cd5\uff0c\u4ee5\u53ca\u5b83\u4eec\u5728\u4e0d\u540c\u573a\u666f\u4e2d\u7684\u5e94\u7528\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u4f7f\u7528<code>end<\/code>\u53c2\u6570<\/p>\n<\/p>\n<p><p><code>end<\/code>\u53c2\u6570\u662f<code>print()<\/code>\u51fd\u6570\u7684\u4e00\u90e8\u5206\uff0c\u5b83\u5141\u8bb8\u6211\u4eec\u5b9a\u4e49\u8f93\u51fa\u7ed3\u675f\u65f6\u7684\u5b57\u7b26\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u9ed8\u8ba4\u884c\u4e3a<\/strong><br \/>\u5f53\u4f7f\u7528<code>print()<\/code>\u51fd\u6570\u65f6\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5b83\u5728\u8f93\u51fa\u540e\u6dfb\u52a0\u4e00\u4e2a\u6362\u884c\u7b26\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">print(&quot;Hello&quot;)<\/p>\n<p>print(&quot;World&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8f93\u51fa\u7ed3\u679c\u4e3a\uff1a<\/p>\n<\/p>\n<p><pre><code>Hello<\/p>\n<p>World<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6539\u53d8<code>end<\/code>\u53c2\u6570<\/strong><br \/>\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4fee\u6539<code>end<\/code>\u53c2\u6570\u7684\u503c\uff0c\u6765\u63a7\u5236\u8f93\u51fa\u7ed3\u675f\u65f6\u7684\u884c\u4e3a\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">print(&quot;Hello&quot;, end=&quot; &quot;)<\/p>\n<p>print(&quot;World&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8f93\u51fa\u7ed3\u679c\u4e3a\uff1a<\/p>\n<\/p>\n<p><pre><code>Hello World<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u5c06<code>end<\/code>\u53c2\u6570\u7684\u503c\u8bbe\u4e3a\u4e00\u4e2a\u7a7a\u683c\uff0c\u8fd9\u6837\u5728\u7b2c\u4e00\u6b21\u8f93\u51fa\u540e\uff0c\u4e0d\u4f1a\u81ea\u52a8\u6362\u884c\uff0c\u800c\u662f\u6dfb\u52a0\u4e00\u4e2a\u7a7a\u683c\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e8c\u3001\u5b57\u7b26\u4e32\u62fc\u63a5<\/p>\n<\/p>\n<p><p>\u5b57\u7b26\u4e32\u62fc\u63a5\u662f\u4e00\u79cd\u5e38\u7528\u7684\u5b57\u7b26\u4e32\u64cd\u4f5c\u6280\u672f\uff0c\u53ef\u4ee5\u5c06\u591a\u4e2a\u5b57\u7b26\u4e32\u8fde\u63a5\u5728\u4e00\u8d77\uff0c\u5f62\u6210\u4e00\u4e2a\u65b0\u7684\u5b57\u7b26\u4e32\u3002\u5728\u9700\u8981\u8fde\u7eed\u8f93\u51fa\u591a\u4e2a\u5b57\u7b26\u4e32\u65f6\uff0c\u6211\u4eec\u53ef\u4ee5\u5148\u5c06\u5b83\u4eec\u62fc\u63a5\u6210\u4e00\u4e2a\u5b8c\u6574\u7684\u5b57\u7b26\u4e32\uff0c\u7136\u540e\u4e00\u6b21\u6027\u6253\u5370\u8f93\u51fa\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4f7f\u7528<code>+<\/code>\u64cd\u4f5c\u7b26<\/strong><br \/>\u5728Python\u4e2d\uff0c<code>+<\/code>\u64cd\u4f5c\u7b26\u7528\u4e8e\u8fde\u63a5\u4e24\u4e2a\u6216\u591a\u4e2a\u5b57\u7b26\u4e32\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">str1 = &quot;Hello&quot;<\/p>\n<p>str2 = &quot;World&quot;<\/p>\n<p>result = str1 + &quot; &quot; + str2<\/p>\n<p>print(result)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8f93\u51fa\u7ed3\u679c\u4e3a\uff1a<\/p>\n<\/p>\n<p><pre><code>Hello World<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528<code>join()<\/code>\u65b9\u6cd5<\/strong><br \/><code>join()<\/code>\u65b9\u6cd5\u4e5f\u662f\u4e00\u79cd\u5e38\u7528\u7684\u5b57\u7b26\u4e32\u62fc\u63a5\u65b9\u5f0f\uff0c\u5c24\u5176\u9002\u7528\u4e8e\u8fde\u63a5\u591a\u4e2a\u5b57\u7b26\u4e32\u7ec4\u6210\u7684\u5217\u8868\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">words = [&quot;Hello&quot;, &quot;World&quot;]<\/p>\n<p>result = &quot; &quot;.join(words)<\/p>\n<p>print(result)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8f93\u51fa\u7ed3\u679c\u4e3a\uff1a<\/p>\n<\/p>\n<p><pre><code>Hello World<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e09\u3001\u4f7f\u7528<code>sys.stdout.write<\/code>\u65b9\u6cd5<\/p>\n<\/p>\n<p><p><code>sys.stdout.write<\/code>\u662f\u4e00\u4e2a\u66f4\u5e95\u5c42\u7684\u8f93\u51fa\u65b9\u6cd5\uff0c\u4e0e<code>print()<\/code>\u51fd\u6570\u4e0d\u540c\uff0c\u5b83\u4e0d\u4f1a\u5728\u8f93\u51fa\u540e\u81ea\u52a8\u6dfb\u52a0\u6362\u884c\u7b26\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u57fa\u672c\u7528\u6cd5<\/strong><br \/><code>sys.stdout.write<\/code>\u65b9\u6cd5\u76f4\u63a5\u5199\u5165\u6807\u51c6\u8f93\u51fa\u6d41\uff0c\u53ef\u4ee5\u66f4\u7cbe\u786e\u5730\u63a7\u5236\u8f93\u51fa\u683c\u5f0f\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import sys<\/p>\n<p>sys.stdout.write(&quot;Hello&quot;)<\/p>\n<p>sys.stdout.write(&quot; World\\n&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8f93\u51fa\u7ed3\u679c\u4e3a\uff1a<\/p>\n<\/p>\n<p><pre><code>Hello World<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u7ed3\u5408<code>flush()<\/code>\u65b9\u6cd5<\/strong><br \/>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u8f93\u51fa\u53ef\u80fd\u4f1a\u88ab\u7f13\u51b2\u3002\u4e3a\u4e86\u786e\u4fdd\u8f93\u51fa\u7acb\u5373\u663e\u793a\uff0c\u53ef\u4ee5\u7ed3\u5408\u4f7f\u7528<code>flush()<\/code>\u65b9\u6cd5\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import sys<\/p>\n<p>sys.stdout.write(&quot;Processing...&quot;)<\/p>\n<p>sys.stdout.flush()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u6837\u53ef\u4ee5\u786e\u4fdd\u5728\u6267\u884c\u8017\u65f6\u64cd\u4f5c\u4e4b\u524d\uff0c\u63d0\u793a\u4fe1\u606f\u7acb\u5373\u663e\u793a\u5728\u5c4f\u5e55\u4e0a\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u56db\u3001\u5b9e\u9645\u5e94\u7528\u573a\u666f<\/p>\n<\/p>\n<p><p>\u5728\u5b9e\u9645\u7f16\u7a0b\u4e2d\uff0c\u63a7\u5236\u8f93\u51fa\u683c\u5f0f\u662f\u4e00\u9879\u5e38\u89c1\u7684\u9700\u6c42\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u89c1\u7684\u5e94\u7528\u573a\u666f\u53ca\u5176\u89e3\u51b3\u65b9\u6848\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u8fdb\u5ea6\u6761\u663e\u793a<\/strong><br \/>\u5728\u5904\u7406\u5927\u91cf\u6570\u636e\u65f6\uff0c\u8fdb\u5ea6\u6761\u662f\u4e00\u79cd\u5e38\u89c1\u7684\u53cd\u9988\u65b9\u5f0f\u3002\u901a\u8fc7\u63a7\u5236\u8f93\u51fa\u4e0d\u6362\u884c\uff0c\u53ef\u4ee5\u5b9e\u65f6\u66f4\u65b0\u8fdb\u5ea6\u6761\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import time<\/p>\n<p>for i in range(101):<\/p>\n<p>    print(f&quot;\\rProgress: {i}%&quot;, end=&quot;&quot;)<\/p>\n<p>    time.sleep(0.1)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>\\r<\/code>\u7528\u4e8e\u5c06\u5149\u6807\u79fb\u52a8\u5230\u884c\u9996\uff0c\u4ece\u800c\u8986\u76d6\u5f53\u524d\u884c\u7684\u5185\u5bb9\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6570\u636e\u8868\u8f93\u51fa<\/strong><br \/>\u5728\u8f93\u51fa\u683c\u5f0f\u5316\u7684\u6570\u636e\u8868\u65f6\uff0c\u63a7\u5236\u6362\u884c\u53ef\u4ee5\u786e\u4fdd\u8868\u683c\u5bf9\u9f50\uff0c\u4ece\u800c\u63d0\u9ad8\u53ef\u8bfb\u6027\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">data = [<\/p>\n<p>    [&quot;Name&quot;, &quot;Age&quot;, &quot;City&quot;],<\/p>\n<p>    [&quot;Alice&quot;, &quot;30&quot;, &quot;New York&quot;],<\/p>\n<p>    [&quot;Bob&quot;, &quot;25&quot;, &quot;Los Angeles&quot;]<\/p>\n<p>]<\/p>\n<p>for row in data:<\/p>\n<p>    print(&quot; | &quot;.join(row))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8f93\u51fa\u7ed3\u679c\u4e3a\uff1a<\/p>\n<\/p>\n<p><pre><code>Name | Age | City<\/p>\n<p>Alice | 30 | New York<\/p>\n<p>Bob | 25 | Los Angeles<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u65e5\u5fd7\u6587\u4ef6\u5199\u5165<\/strong><br \/>\u5728\u5199\u5165\u65e5\u5fd7\u6587\u4ef6\u65f6\uff0c\u907f\u514d\u81ea\u52a8\u6362\u884c\u53ef\u4ee5\u786e\u4fdd\u65e5\u5fd7\u683c\u5f0f\u7684\u4e00\u81f4\u6027\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">with open(&quot;log.txt&quot;, &quot;a&quot;) as f:<\/p>\n<p>    f.write(&quot;Start processing...&quot;)<\/p>\n<p>    f.write(&quot;Processing completed.\\n&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u6837\u53ef\u4ee5\u786e\u4fdd\u6bcf\u6761\u65e5\u5fd7\u4fe1\u606f\u5728\u4e00\u884c\u5185\u5b8c\u6574\u8bb0\u5f55\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e94\u3001\u603b\u7ed3<\/p>\n<\/p>\n<p><p>\u5728Python\u4e2d\uff0c\u901a\u8fc7\u63a7\u5236\u8f93\u51fa\u683c\u5f0f\uff0c\u6211\u4eec\u53ef\u4ee5\u66f4\u597d\u5730\u6ee1\u8db3\u4e0d\u540c\u573a\u666f\u4e0b\u7684\u9700\u6c42\u3002\u65e0\u8bba\u662f\u901a\u8fc7<code>print()<\/code>\u51fd\u6570\u7684<code>end<\/code>\u53c2\u6570\uff0c\u8fd8\u662f\u901a\u8fc7\u5b57\u7b26\u4e32\u62fc\u63a5\u548c<code>sys.stdout.write<\/code>\u65b9\u6cd5\uff0c\u90fd\u63d0\u4f9b\u4e86\u7075\u6d3b\u7684\u89e3\u51b3\u65b9\u6848\u3002\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u6839\u636e\u5177\u4f53\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\uff0c\u53ef\u4ee5\u63d0\u9ad8\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u548c\u6267\u884c\u6548\u7387\u3002\u540c\u65f6\uff0c\u638c\u63e1\u8fd9\u4e9b\u6280\u5de7\u4e5f\u6709\u52a9\u4e8e\u6211\u4eec\u66f4\u597d\u5730\u7406\u89e3Python\u7684\u8f93\u5165\u8f93\u51fa\u673a\u5236\uff0c\u4ece\u800c\u7f16\u5199\u51fa\u66f4\u9ad8\u8d28\u91cf\u7684\u4ee3\u7801\u3002\u5728\u7f16\u5199\u590d\u6742\u7a0b\u5e8f\u65f6\uff0c\u8fd9\u4e9b\u6280\u5de7\u4e0d\u4ec5\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u63a7\u5236\u8f93\u51fa\u683c\u5f0f\uff0c\u8fd8\u53ef\u4ee5\u63d0\u9ad8\u7a0b\u5e8f\u7684\u7528\u6237\u4f53\u9a8c\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u5b9e\u73b0\u4e0d\u6362\u884c\u8f93\u51fa\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u5982\u679c\u60f3\u8981\u5728\u8f93\u51fa\u65f6\u4e0d\u6362\u884c\uff0c\u53ef\u4ee5\u4f7f\u7528<code>print()<\/code>\u51fd\u6570\u7684<code>end<\/code>\u53c2\u6570\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<code>print()<\/code>\u51fd\u6570\u5728\u8f93\u51fa\u7ed3\u675f\u540e\u4f1a\u6362\u884c\uff0c\u800c\u901a\u8fc7\u8bbe\u7f6e<code>end<\/code>\u53c2\u6570\u4e3a\u4e00\u4e2a\u7a7a\u5b57\u7b26\u4e32\uff08<code>&#39;&#39;<\/code>\uff09\uff0c\u53ef\u4ee5\u907f\u514d\u6362\u884c\u3002\u4f8b\u5982\uff1a  <\/p>\n<pre><code class=\"language-python\">print(&quot;Hello&quot;, end=&#39;&#39;)\nprint(&quot; World!&quot;)\n<\/code><\/pre>\n<p>\u8fd9\u6bb5\u4ee3\u7801\u5c06\u8f93\u51fa<code>Hello World!<\/code>\uff0c\u800c\u6ca1\u6709\u6362\u884c\u3002<\/p>\n<p><strong>\u6709\u6ca1\u6709\u5176\u4ed6\u65b9\u6cd5\u53ef\u4ee5\u63a7\u5236\u8f93\u51fa\u683c\u5f0f\uff1f<\/strong><br \/>\u9664\u4e86\u4f7f\u7528<code>print()<\/code>\u7684<code>end<\/code>\u53c2\u6570\u5916\uff0c\u8fd8\u53ef\u4ee5\u4f7f\u7528<code>sys.stdout.write()<\/code>\u6765\u8fdb\u884c\u8f93\u51fa\u3002\u8fd9\u79cd\u65b9\u6cd5\u5141\u8bb8\u4f60\u66f4\u7075\u6d3b\u5730\u63a7\u5236\u8f93\u51fa\u5185\u5bb9\u53ca\u683c\u5f0f\u3002\u793a\u4f8b\u5982\u4e0b\uff1a  <\/p>\n<pre><code class=\"language-python\">import sys\nsys.stdout.write(&quot;Hello &quot;)\nsys.stdout.write(&quot;World!&quot;)\n<\/code><\/pre>\n<p>\u8fd9\u6837\u4e5f\u53ef\u4ee5\u5b9e\u73b0\u4e0d\u6362\u884c\u7684\u8f93\u51fa\u6548\u679c\u3002<\/p>\n<p><strong>\u5728\u4e0d\u540c\u7684Python\u7248\u672c\u4e2d\uff0c\u8f93\u51fa\u63a7\u5236\u6709\u4f55\u53d8\u5316\uff1f<\/strong><br \/>\u5728Python 2\u4e2d\uff0c<code>print<\/code>\u662f\u4e00\u4e2a\u8bed\u53e5\uff0c\u800c\u5728Python 3\u4e2d\uff0c\u5b83\u53d8\u6210\u4e86\u4e00\u4e2a\u51fd\u6570\u3002\u867d\u7136\u5728Python 3\u4e2d\u4f7f\u7528<code>end<\/code>\u53c2\u6570\u53ef\u4ee5\u5b9e\u73b0\u4e0d\u6362\u884c\uff0c\u4f46\u5728Python 2\u4e2d\u9700\u8981\u4f7f\u7528\u9017\u53f7\u6765\u907f\u514d\u6362\u884c\uff0c\u4f8b\u5982\uff1a  <\/p>\n<pre><code class=\"language-python\">print &quot;Hello&quot;,\nprint &quot; World!&quot;\n<\/code><\/pre>\n<p>\u7136\u800c\uff0c\u8003\u8651\u5230Python 2\u5df2\u4e0d\u518d\u7ef4\u62a4\uff0c\u5efa\u8bae\u4f7f\u7528Python 3\u6765\u8fdb\u884c\u5f00\u53d1\u548c\u8f93\u51fa\u63a7\u5236\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python\u4e2d\uff0c\u7981\u6b62\u8f93\u51fa\u6362\u884c\u53ef\u4ee5\u4f7f\u7528end\u53c2\u6570\u3001\u7ed3\u5408\u5b57\u7b26\u4e32\u62fc\u63a5\u3001\u4f7f\u7528sys.stdout.write\u65b9\u6cd5\u3002\u8fd9 [&hellip;]","protected":false},"author":3,"featured_media":1014455,"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\/1014447"}],"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=1014447"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1014447\/revisions"}],"predecessor-version":[{"id":1014456,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1014447\/revisions\/1014456"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1014455"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1014447"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1014447"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1014447"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}