{"id":1036762,"date":"2024-12-31T12:09:33","date_gmt":"2024-12-31T04:09:33","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1036762.html"},"modified":"2024-12-31T12:09:35","modified_gmt":"2024-12-31T04:09:35","slug":"cmd%e4%b8%ad%e8%bf%90%e8%a1%8cpython%e5%a6%82%e4%bd%95%e6%8d%a2%e8%a1%8c%e4%b8%8d%e8%bf%90%e8%a1%8c","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1036762.html","title":{"rendered":"cmd\u4e2d\u8fd0\u884cpython\u5982\u4f55\u6362\u884c\u4e0d\u8fd0\u884c"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2024\/12\/2e300943-35c9-4c81-92b8-33331b5973e3.webp?x-oss-process=image\/auto-orient,1\/format,webp\" alt=\"cmd\u4e2d\u8fd0\u884cpython\u5982\u4f55\u6362\u884c\u4e0d\u8fd0\u884c\" \/><\/p>\n<p><p> <strong>\u5728CMD\u4e2d\u8fd0\u884cPython\u65f6\u6362\u884c\u800c\u4e0d\u8fd0\u884c\uff0c\u53ef\u4ee5\u4f7f\u7528\u53cd\u659c\u6760\uff08\\\uff09\u6216\u8005\u5728\u4ea4\u4e92\u6a21\u5f0f\u4e2d\u4f7f\u7528\u62ec\u53f7\u3002<\/strong>\u4f7f\u7528\u53cd\u659c\u6760\u53ef\u4ee5\u5c06\u4e00\u884c\u4ee3\u7801\u5206\u6210\u591a\u884c\uff0cPython\u89e3\u91ca\u5668\u4f1a\u5c06\u5b83\u4eec\u89c6\u4e3a\u4e00\u6761\u8fde\u7eed\u7684\u6307\u4ee4\u3002\u53e6\u5916\uff0c\u5728\u4ea4\u4e92\u6a21\u5f0f\u4e0b\uff0c\u53ef\u4ee5\u901a\u8fc7\u62ec\u53f7\u6765\u4e66\u5199\u591a\u884c\u4ee3\u7801\uff0c\u76f4\u5230\u62ec\u53f7\u95ed\u5408\u65f6\u624d\u4f1a\u6267\u884c\u3002<\/p>\n<\/p>\n<p><p>\u8981\u8be6\u7ec6\u7406\u89e3\u8fd9\u4e9b\u65b9\u6cd5\uff0c\u4e0b\u9762\u5c06\u4ecb\u7ecd\u5982\u4f55\u5728CMD\u4e2d\u5b9e\u73b0\u5b83\u4eec\uff0c\u5e76\u8fdb\u4e00\u6b65\u63a2\u8ba8\u5b83\u4eec\u7684\u5e94\u7528\u548c\u6ce8\u610f\u4e8b\u9879\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u4f7f\u7528\u53cd\u659c\u6760\uff08\\\uff09\u6362\u884c<\/p>\n<\/p>\n<p><p>\u5f53\u5728CMD\u4e2d\u7f16\u5199Python\u811a\u672c\u65f6\uff0c\u5982\u679c\u4e00\u884c\u4ee3\u7801\u8fc7\u957f\u6216\u9700\u8981\u5206\u591a\u884c\u7f16\u5199\uff0c\u53ef\u4ee5\u4f7f\u7528\u53cd\u659c\u6760\u4f5c\u4e3a\u884c\u7eed\u6807\u8bb0\u3002\u53cd\u659c\u6760\u544a\u8bc9Python\u89e3\u91ca\u5668\u4e0b\u4e00\u884c\u662f\u5f53\u524d\u884c\u7684\u5ef6\u7eed\u3002\u4f7f\u7528\u8fd9\u79cd\u65b9\u6cd5\u53ef\u4ee5\u4f7f\u4ee3\u7801\u66f4\u6613\u8bfb\uff0c\u5e76\u4e14\u4e0d\u7acb\u5373\u6267\u884c\u3002<\/p>\n<\/p>\n<p><h3>\u793a\u4f8b\uff1a<\/h3>\n<\/p>\n<p><pre><code class=\"language-python\">print(&quot;This is a long line of code \\<\/p>\n<p>that is being continued onto the next line&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u5c3d\u7ba1\u4ee3\u7801\u5206\u6210\u4e86\u4e24\u884c\uff0c\u4f46\u89e3\u91ca\u5668\u4f1a\u5c06\u5176\u89c6\u4e3a\u4e00\u884c\u3002<\/p>\n<\/p>\n<p><p><strong>\u8be6\u7ec6\u63cf\u8ff0\uff1a<\/strong><\/p>\n<p>\u4f7f\u7528\u53cd\u659c\u6760\u8fdb\u884c\u6362\u884c\u7684\u597d\u5904\u662f\u53ef\u4ee5\u4fdd\u6301\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\uff0c\u7279\u522b\u662f\u5728\u7f16\u5199\u957f\u5b57\u7b26\u4e32\u3001\u590d\u6742\u7684\u6761\u4ef6\u6216\u591a\u53c2\u6570\u51fd\u6570\u8c03\u7528\u65f6\u3002\u4f8b\u5982\uff0c\u5728\u7f16\u5199\u957f\u5b57\u7b26\u4e32\u65f6\uff0c\u76f4\u63a5\u5728\u4e00\u884c\u4e2d\u7f16\u5199\u4f1a\u4f7f\u4ee3\u7801\u53d8\u5f97\u96be\u4ee5\u9605\u8bfb\u548c\u7ef4\u62a4\uff0c\u800c\u4f7f\u7528\u53cd\u659c\u6760\u53ef\u4ee5\u5c06\u5176\u5206\u5272\u6210\u591a\u884c\uff0c\u4fdd\u6301\u4ee3\u7801\u7684\u6574\u6d01\u548c\u6e05\u6670\u3002<\/p>\n<\/p>\n<p><h3>\u793a\u4f8b\uff1a<\/h3>\n<\/p>\n<p><pre><code class=\"language-python\">long_string = &quot;This is a very long string that is being continued \\<\/p>\n<p>onto the next line for better readability and m<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>ntenance.&quot;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4e8c\u3001\u4f7f\u7528\u62ec\u53f7\u6362\u884c<\/p>\n<\/p>\n<p><p>\u5728Python\u4e2d\uff0c\u62ec\u53f7\uff08\u5706\u62ec\u53f7\u3001\u5c0f\u62ec\u53f7\uff09\u3001\u65b9\u62ec\u53f7\u548c\u5927\u62ec\u53f7\u4e5f\u53ef\u4ee5\u7528\u4e8e\u591a\u884c\u7f16\u5199\u4ee3\u7801\u3002\u5728\u62ec\u53f7\u5185\uff0cPython\u4f1a\u81ea\u52a8\u5ffd\u7565\u6362\u884c\u7b26\uff0c\u76f4\u5230\u62ec\u53f7\u95ed\u5408\u65f6\u624d\u4f1a\u6267\u884c\u4ee3\u7801\u3002<\/p>\n<\/p>\n<p><h3>\u793a\u4f8b\uff1a<\/h3>\n<\/p>\n<p><pre><code class=\"language-python\">result = (<\/p>\n<p>    1 + 2 + 3 +<\/p>\n<p>    4 + 5 + 6<\/p>\n<p>)<\/p>\n<p>print(result)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6240\u6709\u7684\u52a0\u6cd5\u64cd\u4f5c\u90fd\u5728\u62ec\u53f7\u5185\uff0c\u76f4\u5230\u6700\u540e\u4e00\u4e2a\u62ec\u53f7\u95ed\u5408\u65f6\uff0cPython\u624d\u4f1a\u6267\u884c\u6574\u4e2a\u8868\u8fbe\u5f0f\u3002<\/p>\n<\/p>\n<p><p><strong>\u8be6\u7ec6\u63cf\u8ff0\uff1a<\/strong><\/p>\n<p>\u4f7f\u7528\u62ec\u53f7\u7684\u4f18\u52bf\u5728\u4e8e\u5b83\u4e0d\u4ec5\u53ef\u4ee5\u7528\u4e8e\u957f\u5b57\u7b26\u4e32\uff0c\u8fd8\u53ef\u4ee5\u7528\u4e8e\u5217\u8868\u3001\u5b57\u5178\u548c\u5143\u7ec4\u7b49\u6570\u636e\u7ed3\u6784\u7684\u5b9a\u4e49\u3002\u8fd9\u6837\uff0c\u4ee3\u7801\u770b\u8d77\u6765\u66f4\u52a0\u6574\u6d01\uff0c\u4e5f\u66f4\u5bb9\u6613\u7406\u89e3\u3002<\/p>\n<\/p>\n<p><h3>\u793a\u4f8b\uff1a<\/h3>\n<\/p>\n<p><pre><code class=\"language-python\">my_list = [<\/p>\n<p>    &quot;apple&quot;,<\/p>\n<p>    &quot;banana&quot;,<\/p>\n<p>    &quot;cherry&quot;<\/p>\n<p>]<\/p>\n<p>my_dict = {<\/p>\n<p>    &quot;name&quot;: &quot;John&quot;,<\/p>\n<p>    &quot;age&quot;: 30,<\/p>\n<p>    &quot;city&quot;: &quot;New York&quot;<\/p>\n<p>}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4e09\u3001\u5728\u4ea4\u4e92\u6a21\u5f0f\u4e2d\u7684\u5e94\u7528<\/p>\n<\/p>\n<p><p>\u5728Python\u7684\u4ea4\u4e92\u6a21\u5f0f\uff08REPL\uff09\u4e2d\uff0c\u4f7f\u7528\u53cd\u659c\u6760\u6216\u62ec\u53f7\u6362\u884c\u540c\u6837\u9002\u7528\u3002\u4ea4\u4e92\u6a21\u5f0f\u5141\u8bb8\u4f60\u9010\u884c\u8f93\u5165\u548c\u6267\u884cPython\u4ee3\u7801\uff0c\u4f46\u6709\u65f6\u9700\u8981\u8f93\u5165\u591a\u884c\u4ee3\u7801\u624d\u80fd\u5f62\u6210\u4e00\u4e2a\u5b8c\u6574\u7684\u8868\u8fbe\u5f0f\u6216\u8bed\u53e5\u3002\u6b64\u65f6\uff0c\u53cd\u659c\u6760\u548c\u62ec\u53f7\u5c31\u663e\u5f97\u5c24\u4e3a\u91cd\u8981\u3002<\/p>\n<\/p>\n<p><h3>\u793a\u4f8b\uff1a<\/h3>\n<\/p>\n<p><pre><code class=\"language-python\">&gt;&gt;&gt; result = (<\/p>\n<p>...     1 + 2 + 3 +<\/p>\n<p>...     4 + 5 + 6<\/p>\n<p>... )<\/p>\n<p>&gt;&gt;&gt; print(result)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u56db\u3001\u6ce8\u610f\u4e8b\u9879<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4ee3\u7801\u98ce\u683c<\/strong>\uff1a\u867d\u7136\u53cd\u659c\u6760\u548c\u62ec\u53f7\u90fd\u53ef\u4ee5\u7528\u4e8e\u591a\u884c\u4ee3\u7801\uff0c\u4f46\u6700\u597d\u6839\u636e\u5177\u4f53\u60c5\u51b5\u9009\u62e9\u9002\u5408\u7684\u65b9\u6cd5\u3002\u4e00\u822c\u6765\u8bf4\uff0c\u4f7f\u7528\u62ec\u53f7\u66f4\u7b26\u5408Python\u7684\u4ee3\u7801\u98ce\u683c\u6307\u5357\uff08PEP 8\uff09\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u907f\u514d\u9519\u8bef<\/strong>\uff1a\u5728\u4f7f\u7528\u53cd\u659c\u6760\u65f6\uff0c\u8981\u786e\u4fdd\u53cd\u659c\u6760\u540e\u6ca1\u6709\u4efb\u4f55\u5b57\u7b26\uff08\u5305\u62ec\u7a7a\u683c\uff09\uff0c\u5426\u5219\u4f1a\u5bfc\u81f4\u8bed\u6cd5\u9519\u8bef\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4fdd\u6301\u4e00\u81f4\u6027<\/strong>\uff1a\u65e0\u8bba\u9009\u62e9\u54ea\u79cd\u65b9\u6cd5\uff0c\u90fd\u5e94\u5728\u6574\u4e2a\u9879\u76ee\u4e2d\u4fdd\u6301\u4e00\u81f4\u6027\uff0c\u4ee5\u63d0\u9ad8\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u548c\u7ef4\u62a4\u6027\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e94\u3001\u603b\u7ed3<\/p>\n<\/p>\n<p><p>\u5728CMD\u4e2d\u8fd0\u884cPython\u65f6\uff0c\u6362\u884c\u800c\u4e0d\u7acb\u5373\u6267\u884c\u4ee3\u7801\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528\u53cd\u659c\u6760\u6216\u62ec\u53f7\u6765\u5b9e\u73b0\u3002\u53cd\u659c\u6760\u7528\u4e8e\u7b80\u5355\u7684\u884c\u7eed\uff0c\u800c\u62ec\u53f7\u5219\u9002\u7528\u4e8e\u66f4\u590d\u6742\u7684\u8868\u8fbe\u5f0f\u548c\u6570\u636e\u7ed3\u6784\u5b9a\u4e49\u3002\u8fd9\u4e24\u79cd\u65b9\u6cd5\u4e0d\u4ec5\u63d0\u9ad8\u4e86\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\uff0c\u8fd8\u4f7f\u5f97\u7f16\u5199\u548c\u8c03\u8bd5\u4ee3\u7801\u66f4\u52a0\u65b9\u4fbf\u3002\u5728\u5b9e\u9645\u7f16\u7a0b\u4e2d\uff0c\u6839\u636e\u5177\u4f53\u60c5\u51b5\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\uff0c\u5e76\u4fdd\u6301\u4ee3\u7801\u98ce\u683c\u7684\u4e00\u81f4\u6027\uff0c\u5c06\u6709\u52a9\u4e8e\u63d0\u5347\u4ee3\u7801\u8d28\u91cf\u548c\u5f00\u53d1\u6548\u7387\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728CMD\u4e2d\u8f93\u5165\u591a\u884cPython\u4ee3\u7801\u800c\u4e0d\u7acb\u5373\u6267\u884c\uff1f<\/strong><br \/>\u5728CMD\u4e2d\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u53cd\u659c\u6760 <code>\\<\/code> \u4f5c\u4e3a\u7eed\u884c\u7b26\uff0c\u5c06\u957f\u884c\u4ee3\u7801\u62c6\u5206\u4e3a\u591a\u884c\u3002\u8fd9\u6837\u53ef\u4ee5\u5728\u8f93\u5165\u65f6\u4fdd\u6301\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\uff0c\u800c\u4e0d\u7acb\u5373\u6267\u884c\u3002\u4f8b\u5982\uff1a  <\/p>\n<pre><code class=\"language-python\">print(&quot;\u8fd9\u662f\u4e00\u6bb5\u5f88\u957f\u7684\u4ee3\u7801\uff0c\\\n\u53ef\u4ee5\u5206\u4e3a\u591a\u884c\u8f93\u5165&quot;)\n<\/code><\/pre>\n<p><strong>\u5728CMD\u4e2d\u8fd0\u884cPython\u65f6\uff0c\u5982\u4f55\u67e5\u770b\u5f53\u524d\u884c\u7684\u8f93\u5165\u800c\u4e0d\u6267\u884c\uff1f<\/strong><br \/>\u60a8\u53ef\u4ee5\u6309\u4e0b <code>Ctrl + Z<\/code> \u548c <code>Enter<\/code> \u6765\u7ed3\u675f\u8f93\u5165\u5e76\u8fd4\u56de\u5230\u547d\u4ee4\u63d0\u793a\u7b26\uff0c\u800c\u4e0d\u8fd0\u884c\u5f53\u524d\u8f93\u5165\u7684\u4ee3\u7801\u3002\u8fd9\u6837\u53ef\u4ee5\u4f7f\u60a8\u5728\u8f93\u5165\u591a\u884c\u4ee3\u7801\u65f6\u8fdb\u884c\u68c0\u67e5\u548c\u4fee\u6539\u3002<\/p>\n<p><strong>\u5728CMD\u4e2d\u5982\u4f55\u4f7f\u7528\u6ce8\u91ca\u6765\u5206\u9694\u4ee3\u7801\u884c\uff1f<\/strong><br \/>\u5728CMD\u4e2d\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528 <code>#<\/code> \u7b26\u53f7\u6765\u6dfb\u52a0\u6ce8\u91ca\uff0c\u8fd9\u6837\u5728\u8f93\u5165\u4ee3\u7801\u65f6\u53ef\u4ee5\u52a0\u5165\u8bf4\u660e\u800c\u4e0d\u4f1a\u5f71\u54cd\u4ee3\u7801\u7684\u6267\u884c\u3002\u4f8b\u5982\uff1a  <\/p>\n<pre><code class=\"language-python\"># \u8fd9\u662f\u4e00\u4e2a\u6ce8\u91ca\nprint(&quot;\u8fd9\u884c\u4ee3\u7801\u4f1a\u6267\u884c&quot;)\n# print(&quot;\u8fd9\u884c\u4ee3\u7801\u4e0d\u4f1a\u6267\u884c&quot;)\n<\/code><\/pre>\n<p>\u901a\u8fc7\u8fd9\u6837\u7684\u65b9\u5f0f\uff0c\u53ef\u4ee5\u6709\u6548\u5730\u5728\u4ee3\u7801\u4e2d\u6dfb\u52a0\u89e3\u91ca\u548c\u6ce8\u91ca\uff0c\u800c\u4e0d\u5f71\u54cd\u7a0b\u5e8f\u7684\u8fd0\u884c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728CMD\u4e2d\u8fd0\u884cPython\u65f6\u6362\u884c\u800c\u4e0d\u8fd0\u884c\uff0c\u53ef\u4ee5\u4f7f\u7528\u53cd\u659c\u6760\uff08\\\uff09\u6216\u8005\u5728\u4ea4\u4e92\u6a21\u5f0f\u4e2d\u4f7f\u7528\u62ec\u53f7\u3002\u4f7f\u7528\u53cd\u659c\u6760\u53ef\u4ee5\u5c06\u4e00\u884c\u4ee3 [&hellip;]","protected":false},"author":3,"featured_media":1036771,"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\/1036762"}],"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=1036762"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1036762\/revisions"}],"predecessor-version":[{"id":1036773,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1036762\/revisions\/1036773"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1036771"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1036762"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1036762"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1036762"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}