{"id":70121,"date":"2024-01-29T16:04:18","date_gmt":"2024-01-29T08:04:18","guid":{"rendered":"https:\/\/docs.pingcode.com\/?p=70121"},"modified":"2024-01-29T16:04:18","modified_gmt":"2024-01-29T08:04:18","slug":"python-%e4%b8%bb%e6%b5%81%e6%98%af%e5%93%aa%e4%b8%aa%e7%89%88%e6%9c%ac","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/70121.html","title":{"rendered":"Python \u4e3b\u6d41\u662f\u54ea\u4e2a\u7248\u672c"},"content":{"rendered":"<p><strong>PYTHON\u4e3b\u6d41\u7248\u672c\u76ee\u524d\u662fPython 3\u3001\u5b83\u63d0\u4f9b\u4e86\u66f4\u597d\u7684\u8bed\u8a00\u7279\u6027\u3002<\/strong> Python 2\u5df2\u4e8e2020\u5e74\u521d\u505c\u6b62\u5b98\u65b9\u652f\u6301\uff0c\u610f\u5473\u7740\u4e0d\u518d\u6709\u5b89\u5168\u66f4\u65b0\u548c\u6539\u8fdb\u3002\u5927\u90e8\u5206\u7ec4\u7ec7\u548c\u9879\u76ee\u5df2\u7ecf\u8f6c\u79fb\u5230Python 3\uff0c\u540e\u8005\u6301\u7eed\u5f97\u5230\u6539\u8fdb\u548c\u7ef4\u62a4\u3002<\/p>\n<p><strong>Python 3\u7684\u4f18\u52bf\u5728\u4e8e\u6539\u8fdb\u4e86\u8bed\u6cd5\u548c\u5e93\u652f\u6301\u3001\u63d0\u4f9b\u4e86\u66f4\u597d\u7684\u6027\u80fd\u3002<\/strong> \u5b83\u7684\u6539\u8fdb\u5305\u62ec\u66f4\u597d\u7684\u5b57\u7b26\u4e32\u5904\u7406\u3001\u5bf9\u4e8e\u73b0\u4ee3\u786c\u4ef6\u7684\u66f4\u597d\u4f18\u5316\u3001\u66f4\u6e05\u6670\u7684\u4ee3\u7801\u98ce\u683c\u4ee5\u53ca\u63d0\u9ad8\u4e86\u5f00\u53d1\u8005\u7f16\u7a0b\u6548\u7387\u7684\u8bed\u6cd5\u7cd6\u3002<\/p>\n<h2><strong>\u4e00\u3001PYTHON 3\u7684\u65b0\u7279\u6027\u548c\u6539\u8fdb<\/strong><\/h2>\n<p>Python\u8bed\u8a00\u7684\u91cd\u5927\u66f4\u65b0\u901a\u5e38\u610f\u5473\u7740\u65e9\u671f\u7684\u4e0d\u8db3\u4e4b\u5904\u5df2\u7ecf\u88ab\u7ea0\u6b63\uff0c\u540c\u65f6\u5f15\u5165\u4e86\u5168\u65b0\u7684\u8bed\u8a00\u7279\u6027\u3002<strong>Python 3\u76f8\u5bf9\u4e8ePython 2\uff0c\u786e\u5b9e\u5728\u591a\u4e2a\u5c42\u9762\u4e0a\u5b9e\u73b0\u4e86\u6539\u8fdb\u3002<\/strong> \u8fd9\u5305\u62ec\u66f4\u52a0\u4e00\u81f4\u7684\u8bed\u6cd5\u3001\u6539\u8fdb\u7684Unicode\u652f\u6301\uff08\u5728Python 3\u4e2d\uff0c\u5b57\u7b26\u4e32\u9ed8\u8ba4\u4e3aUnicode\uff09\uff0c\u4ee5\u53ca\u65b0\u7684\u5185\u7f6e\u529f\u80fd\u548c\u5e93\u7684\u66f4\u65b0\u3002<\/p>\n<p>\u4e00\u65b9\u9762\uff0cPython 3\u7b80\u5316\u4e86\u8bb8\u591a\u6613\u6df7\u6dc6\u7684\u8bed\u6cd5\uff0c\u6bd4\u5982print\u8bed\u53e5\u53d8\u6210\u4e86print()\u51fd\u6570\uff0c\u8fd9\u4f7f\u5f97\u8bed\u6cd5\u66f4\u52a0\u7edf\u4e00\u4e14\u6e05\u6670\u3002<strong>\u5b83\u8fd8\u5f15\u5165\u4e86\u65b0\u7684\u6570\u636e\u7c7b\u578b\u5982bytes\u548cbytearray\uff0c\u8fd9\u6709\u52a9\u4e8e\u5904\u7406\u4e8c\u8fdb\u5236\u6570\u636e\u3002<\/strong><\/p>\n<p>\u53e6\u4e00\u65b9\u9762\uff0c\u6027\u80fd\u663e\u8457\u63d0\u5347\u3002\u4f8b\u5982\uff0cPython 3\u4e2d\u7684range()\u51fd\u6570\u73b0\u5728\u8868\u73b0\u5f97\u50cf\u662fxrange()\u4e00\u6837\uff0c\u8fd9\u4f7f\u5f97\u5927\u6570\u636e\u96c6\u7684\u5faa\u73af\u5904\u7406\u66f4\u52a0\u9ad8\u6548\u3002\u7528\u4e8e\u5f02\u6b65\u7f16\u7a0b\u7684asyncio\u5e93\u4e5f\u662fPython 3\u7684\u4e00\u5927\u4eae\u70b9\uff0c\u5b83\u4f7f\u5f97\u5e76\u53d1\u7f16\u7a0b\u53d8\u5f97\u66f4\u52a0\u7b80\u5355\u3002<\/p>\n<h2><strong>\u4e8c\u3001PYTHON 2\u4e0ePYTHON 3\u7684\u5dee\u5f02<\/strong><\/h2>\n<p><strong>Python 2\u548cPython 3\u4e4b\u95f4\u7684\u5dee\u5f02\u662f\u591a\u65b9\u9762\u7684\u3002<\/strong> \u5728\u4e00\u4e9b\u7cfb\u7edf\u548c\u65e7\u9879\u76ee\u4e2d\uff0cPython 2\u4f9d\u7136\u88ab\u5e7f\u6cdb\u4f7f\u7528\uff0c\u4f46\u7531\u4e8e\u4e0d\u518d\u6709\u5b98\u65b9\u652f\u6301\uff0c\u8fd9\u79cd\u4f7f\u7528\u662f\u6709\u98ce\u9669\u7684\u3002 <\/p>\n<p>\u6bd4\u8f83\u7a81\u51fa\u7684\u5dee\u5f02\u5305\u62ec\u5bf9\u6253\u5370\u8bed\u53e5\u7684\u5904\u7406\u3001\u6574\u6570\u9664\u6cd5\u7684\u7ed3\u679c\u3001\u4ee5\u53ca\u4e00\u4e9b\u6807\u51c6\u5e93\u51fd\u6570\u7684\u53d8\u5316\u3002\u4f8b\u5982\uff0c\u5728Python 2\u4e2d\uff0c\u6574\u6570\u9664\u6cd5\u4f1a\u9ed8\u8ba4\u5f97\u5230\u6574\u6570\u7ed3\u679c\uff0c\u9664\u975e\u64cd\u4f5c\u6570\u4e4b\u4e00\u662f\u6d6e\u70b9\u6570\uff1b\u800c\u5728Python 3\u4e2d\uff0c\u6574\u6570\u9664\u6cd5\u4f7f\u7528\u201c\/\/\u201d\u6765\u83b7\u53d6\u6574\u6570\u7ed3\u679c\uff0c\u201c\/\u201d\u5219\u603b\u662f\u8fd4\u56de\u4e00\u4e2a\u6d6e\u70b9\u6570\u7ed3\u679c\u3002<\/p>\n<h2><strong>\u4e09\u3001PYTHON 3\u7684\u7248\u672c\u8fed\u4ee3\u548c\u9009\u62e9<\/strong><\/h2>\n<p>Python 3\u81ea\u63a8\u51fa\u4ee5\u6765\uff0c\u7ecf\u5386\u4e86\u591a\u4e2a\u7248\u672c\u7684\u8fed\u4ee3\u3002<strong>\u5229\u7528\u6700\u65b0\u7248\u672cPython 3\u901a\u5e38\u80fd\u4eab\u6709\u6027\u80fd\u4e0a\u7684\u63d0\u5347\u548c\u66f4\u591a\u65b0\u7279\u6027\u3002<\/strong> <\/p>\n<p>\u5f00\u53d1\u8005\u5728\u9009\u62e9Python\u7248\u672c\u65f6\uff0c\u901a\u5e38\u4f1a\u8003\u8651\u5230\u5e93\u7684\u517c\u5bb9\u6027\u3001\u7cfb\u7edf\u7684\u8981\u6c42\u4ee5\u53ca\u8bed\u8a00\u7684\u65b0\u7279\u6027\u3002\u6709\u65f6\uff0c\u9879\u76ee\u6216\u7ec4\u7ec7\u4e5f\u4f1a\u9009\u62e9\u67d0\u4e2a\u7279\u5b9a\u7684Python 3\u5c0f\u7248\u672c\u6765\u4fdd\u8bc1\u7a33\u5b9a\u6027\uff0c\u800c\u4e0d\u6025\u4e8e\u8fc1\u79fb\u5230\u6700\u65b0\u7248\u672c\u3002<\/p>\n<h2><strong>\u56db\u3001\u8fc1\u79fb\u81f3PYTHON 3\u7684\u5fc5\u8981\u6027\u4e0e\u7b56\u7565<\/strong><\/h2>\n<p>\u9762\u5bf9Python 3\uff0c\u5f88\u591a\u56e2\u961f\u548c\u9879\u76ee\u9762\u4e34\u7740\u4ecePython 2\u8fc1\u79fb\u7684\u4efb\u52a1\u3002<strong>\u8fd9\u4e00\u8fc1\u79fb\u4e0d\u4ec5\u662f\u4e3a\u4e86\u7ef4\u6301\u9879\u76ee\u7684\u5b89\u5168\uff0c\u4e5f\u662f\u4e3a\u4e86\u5229\u7528Python 3\u5e26\u6765\u7684\u5404\u79cd\u597d\u5904\u3002<\/strong><\/p>\n<p>\u8fc1\u79fb\u7684\u8fc7\u7a0b\u9700\u8981\u8c28\u614e\u89c4\u5212\u3002\u8fd9\u6d89\u53ca\u5230\u5bf9\u73b0\u6709\u4ee3\u7801\u5e93\u7684\u5ba1\u6838\u3001\u66f4\u65b0\u4f9d\u8d56\u5e93\u3001\u4fee\u6b63\u4e0d\u517c\u5bb9\u7684\u4ee3\u7801\uff0c\u4ee5\u53ca\u8fdb\u884c\u5168\u9762\u7684\u6d4b\u8bd5\u3002\u5bf9\u4e8e\u5927\u578b\u9879\u76ee\uff0c\u8fd9\u53ef\u80fd\u662f\u4e00\u9879\u957f\u671f\u800c\u6301\u7eed\u7684\u5de5\u4f5c\u3002\u5c3d\u7ba1\u5982\u6b64\uff0c\u968f\u7740\u65f6\u95f4\u7684\u63a8\u79fb\uff0cPython 3\u7684\u4f18\u52bf\u4f7f\u5f97\u8fc1\u79fb\u7684\u52aa\u529b\u53d8\u5f97\u503c\u5f97\u3002<\/p>\n<p> <strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><strong>Python\u4e3b\u8981\u6709\u54ea\u4e9b\u7248\u672c\uff1f<\/strong><\/p>\n<p>Python\u4e3b\u8981\u6709\u4e24\u4e2a\u4e3b\u8981\u7248\u672c\uff1aPython 2.x\u548cPython 3.x\u3002Python 2.x\u662f\u8001\u7248\u672c\uff0c\u76ee\u524d\u5df2\u7ecf\u505c\u6b62\u7ef4\u62a4\u3002Python 3.x\u662f\u5f53\u524d\u4e3b\u6d41\u7684\u7248\u672c\uff0c\u5b98\u65b9\u63a8\u8350\u4f7f\u7528Python 3. <\/p>\n<p><strong>Python 3.x\u6709\u54ea\u4e9b\u91cd\u8981\u7279\u6027\uff1f<\/strong><\/p>\n<p>Python 3.x\u76f8\u5bf9\u4e8ePython 2.x\u6709\u8bb8\u591a\u65b0\u7279\u6027\uff0c\u5305\u62ec\u66f4\u4e25\u683c\u7684\u8bed\u6cd5\u3001\u66f4\u597d\u7684Unicode\u652f\u6301\u3001\u534f\u7a0b\u548c\u5f02\u6b65\u7f16\u7a0b\u7684\u6807\u51c6\u5316\u7b49\u7b49\u3002\u6b64\u5916\uff0cPython 3.x\u4e5f\u5bf9\u4e00\u4e9b\u8fc7\u65f6\u7684\u7279\u6027\u8fdb\u884c\u4e86\u6e05\u7406\u548c\u79fb\u9664\uff0c\u4f7f\u5f97\u8bed\u8a00\u66f4\u52a0\u73b0\u4ee3\u5316\u548c\u89c4\u8303\u5316\u3002<\/p>\n<p><strong>\u5982\u4f55\u9009\u62e9Python\u7248\u672c\uff1f<\/strong><\/p>\n<p>\u5bf9\u4e8e\u65b0\u9879\u76ee\uff0c\u5b98\u65b9\u5f3a\u70c8\u63a8\u8350\u4f7f\u7528Python 3.x\uff0c\u56e0\u4e3a\u5b83\u662f\u76ee\u524d\u7684\u4e3b\u6d41\u7248\u672c\uff0c\u5e76\u4e14\u4f1a\u83b7\u5f97\u5b98\u65b9\u957f\u671f\u7684\u652f\u6301\u548c\u7ef4\u62a4\u3002\u5bf9\u4e8e\u9057\u7559\u9879\u76ee\uff0c\u5982\u679c\u8981\u8fc1\u79fb\u81f3Python 3.x\uff0c\u53ef\u80fd\u9700\u8981\u8fdb\u884c\u4e00\u5b9a\u7684\u4ee3\u7801\u8c03\u6574\uff0c\u4f46\u8fd9\u6837\u505a\u6709\u52a9\u4e8e\u786e\u4fdd\u4ee3\u7801\u7684\u957f\u671f\u53ef\u7ef4\u62a4\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"PYTHON\u4e3b\u6d41\u7248\u672c\u76ee\u524d\u662fPython 3\u3001\u5b83\u63d0\u4f9b\u4e86\u66f4\u597d\u7684\u8bed\u8a00\u7279\u6027\u3002 Python 2\u5df2\u4e8e2020\u5e74\u521d\u505c\u6b62\u5b98\u65b9 [&hellip;]","protected":false},"author":1,"featured_media":70123,"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\/70121"}],"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\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=70121"}],"version-history":[{"count":0,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/70121\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/70123"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=70121"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=70121"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=70121"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}