{"id":419759,"date":"2021-04-01T03:53:23","date_gmt":"2021-03-31T19:53:23","guid":{"rendered":"http:\/\/4563.org\/?p=419759"},"modified":"2021-04-01T03:53:23","modified_gmt":"2021-03-31T19:53:23","slug":"%e6%8a%80%e6%9c%af%e6%8f%ad%e7%a7%98-python-3-9-%e6%96%b0%e7%89%b9%e6%80%a7%e9%80%9f%e8%a7%88","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=419759","title":{"rendered":"\u6280\u672f\u63ed\u79d8 | Python 3.9 \u65b0\u7279\u6027\u901f\u89c8"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u6280\u672f\u63ed\u79d8 | Python 3.9 \u65b0\u7279\u6027\u901f\u89c8               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : thinkingmind <\/span>  <span><i><\/i> 0<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u53bb\u5e74\u56fd\u5e86\u5047\u671f\uff0cPython \u793e\u533a\u53d1\u5e03\u4e86 3.9 \u7248\u672c\u7684\u7b2c\u4e00\u4e2a stable release \u3002\u76f8\u6bd4\u4e8e 3.8\uff0cPython 3.9 \u65b0\u7279\u6027\u4f17\u591a\uff0c\u4f46\u4e0d\u5c11\u7279\u6027\u4e0e\u5927\u591a\u6570 Python\u201c\u4f7f\u7528\u8005\u201d\uff08\u800c\u975e CPython \u7684\u8d21\u732e\u8005\u6216\u4f7f\u7528 C \u63a5\u53e3\u7f16\u5199\u6269\u5c55\u7684\u5f00\u53d1\u8005\uff09\u5173\u7cfb\u4e0d\u5927\u3002\u672c\u6587\u5c06\u7ad9\u5728 Python \u201c\u4f7f\u7528\u8005\u201d\u7684\u89d2\u5ea6\uff0c\u7b80\u5355\u4ecb\u7ecd\u65b0\u7279\u6027\u4e2d\u5f88\u53ef\u80fd\u4f1a\u4e0e\u5404\u4f4d\u7684\u65e5\u5e38\u5f00\u53d1\u4ea7\u751f\u5173\u7cfb\u7684\u51e0\u4e2a\u3002<\/p>\n<h1><strong>\u5b57\u5178\u201c\u5e76\u96c6\u201d\u8fd0\u7b97\u7b26<\/strong><\/h1>\n<p> <\/p>\n<p><strong>\u201c\u5e76\u96c6\u201d\u8fd0\u7b97\u7b26<\/strong>\u987e\u540d\u601d\u4e49\u5c31\u662f\u7ed9\u4e24\u4e2a\u5b57\u5178\u53d6\u5e76\uff0c\u5e76\u4ea7\u751f\u65b0\u7684\u5b57\u5178\u5bf9\u8c61\u3002\u719f\u6089 collections \u6807\u51c6\u5e93\u7684\u5f00\u53d1\u8005\u542c\u5230\u8fd9\u4e00\u7279\u6027\u60f3\u5fc5\u5f88\u5bb9\u6613\u8054\u60f3\u5230 ChainMap\uff0c\u4e24\u8005\u7684\u533a\u522b\u662f\u201c\u5e76\u96c6\u201d\u8fd0\u7b97\u7b26\u4f1a\u76f4\u63a5\u4ea7\u751f\u65b0\u7684\u5bf9\u8c61\uff0c\u800c ChainMap \u4ea7\u751f\u7684\u662f\u4e0e\u8f93\u5165\u7684\u5bf9\u8c61\u76f8\u5173\u8054\u7684\u89c6\u56fe\u2014\u2014\u89c6\u56fe\u5bf9\u8c61\u6216\u8f93\u5165\u5bf9\u8c61\u7684\u53d8\u5316\u90fd\u4f1a\u76f4\u63a5\u5bf9\u5bf9\u65b9\u4ea7\u751f\u5f71\u54cd\u3002<\/p>\n<p>\u5b57\u5178\u201c\u5e76\u96c6\u201d\u8fd0\u7b97\u7b26\u53ca\u5176\u76f8\u5bf9\u5e94\u7684\u539f\u5730\u8fd0\u7b97\u7b26\u7684\u6548\u679c\u5982\u56fe\uff1a<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" referrerpolicy=\"no-referrer\" rel=\"noreferrer\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2021\/04\/20210401_6065d5d23a23b.webp\" alt=\"\u6280\u672f\u63ed\u79d8 | Python 3.9 \u65b0\u7279\u6027\u901f\u89c8\" \/><\/p>\n<p>\u4e5f\u8bb8\u6709\u540c\u5b66\u4f1a\u8d28\u7591\u201c\u5e76\u96c6\u201d\u8fd0\u7b97\u7b26\u7684\u610f\u4e49\uff0c\u6bd5\u7adf\u4f7f\u7528\u5982\u4e0b\u7684\u5199\u6cd5\u4e5f\u80fd\u76f8\u5bf9\u7b80\u6d01\u5730\u5408\u5e76\u5b57\u5178\uff1a<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" referrerpolicy=\"no-referrer\" rel=\"noreferrer\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2021\/04\/20210401_6065d5d7aa8d4.webp\" alt=\"\u6280\u672f\u63ed\u79d8 | Python 3.9 \u65b0\u7279\u6027\u901f\u89c8\" \/><\/p>\n<p>\u5c31\u7b14\u8005\u7684\u7406\u89e3\uff08\u4e14\u4e0d\u63d0\u4e0a\u8ff0\u4e09\u79cd\u5199\u6cd5\u6709\u591a\u5c11\u5f00\u53d1\u8005\u80fd\u591f\u60f3\u5230\uff09\uff0c\u201c\u5e76\u96c6\u201d\u8fd0\u7b97\u7b26\u7684\u4f18\u52bf\u5728\u4e8e\u4e0d\u4f1a\u4e22\u5931\u53c2\u4e0e\u5408\u5e76\u5b57\u5178\u7684\u7c7b\u578b\u4fe1\u606f\uff0c\u4e14\u5bf9\u5b57\u5178\u952e\u7684\u7c7b\u578b\u6ca1\u6709\u8981\u6c42\uff1b\u6b64\u5916\uff0c\u7ecf\u8fc7\u7b80\u5355\u6d4b\u8bd5\uff0c\u201c\u5e76\u96c6\u201d\u8fd0\u7b97\u7b26\u5728\u6027\u80fd\u4e0a\u4e5f\u66f4\u6709\u4f18\u52bf\u3002<\/p>\n<h1><strong>\u7c7b\u578b\u63d0\u793a\u7684\u6539\u5584<\/strong><\/h1>\n<p> <\/p>\n<p>Python 3.9 \u4e3a\u5185\u7f6e\u7684\u4ee5\u53ca\u6807\u51c6\u5e93\u4e2d\u7684\u96c6\u5408\u7c7b\u578b\u63d0\u4f9b\u4e86\u7528\u4e8e\u7c7b\u578b\u63d0\u793a\u4e2d\u7684\u6cdb\u578b\u7684\u652f\u6301\u3002\u5982\uff1a<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" referrerpolicy=\"no-referrer\" rel=\"noreferrer\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2021\/04\/20210401_6065d5daf2b55.png\" alt=\"\u6280\u672f\u63ed\u79d8 | Python 3.9 \u65b0\u7279\u6027\u901f\u89c8\" \/><\/p>\n<p>\u8fd9\u4e00\u652f\u6301\u89e3\u51b3\u4e86\u4e00\u76f4\u4ee5\u6765 Python \u4ee3\u7801\u4e2d\u4f1a\u51fa\u73b0\u4e24\u79cd list \uff08 list \u548c typing.List \uff09\u7c7b\u578b\u7684\u5c34\u5c2c\u60c5\u51b5\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u6cdb\u578b\u5316\u7684\u5185\u7f6e\u7c7b\u578b\u4ecd\u7136\u652f\u6301\u5b9e\u4f8b\u5316\uff0c\u4f46\u4e0d\u80fd\u88ab\u7528\u4e8e isinstance \u548c issubclass \u5224\u65ad\uff0c\u8fd9\u4e00\u8bbe\u8ba1\u5e94\u8be5 Python \u793e\u533a\u662f\u7ed3\u5408\u4e86\u4ee3\u7801\u8868\u610f\u6027\u548c\u6027\u80fd\u4f5c\u51fa\u7684\u7efc\u5408\u8003\u91cf\uff1a<\/p>\n<p><img decoding=\"async\" alt=\"\u6280\u672f\u63ed\u79d8 | Python 3.9 \u65b0\u7279\u6027\u901f\u89c8\" loading=\"lazy\" referrerpolicy=\"no-referrer\" rel=\"noreferrer\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2021\/04\/20210401_6065d654e3132.jpg\" \/><\/p>\n<p>\u6b64\u5916\uff0ctyping \u5e93\u52a0\u5165\u4e86\u65b0\u7684\u7c7b\u578b Annotated\uff0c\u901a\u8fc7\u4f7f\u7528 Annotated\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u4e3a\u5185\u7f6e\u7684\u6216\u81ea\u5b9a\u4e49\u7684\u7c7b\u578b\u9644\u52a0\u66f4\u591a\u7684\u4fe1\u606f\u3002\u4e00\u79cd\u53ef\u80fd\u7684\u4f7f\u7528\u573a\u666f\uff1aAnnotated \u4e2d\u7684\u7c7b\u578b\u4fe1\u606f\u4f9b IDE \u6216 \u4ee3\u7801\u5ba1\u67e5\u5de5\u5177\u9759\u6001\u5730\u68c0\u67e5\u53d8\u91cf\u7c7b\u578b\uff0c\u800c\u9644\u52a0\u7684\u4fe1\u606f\u5219\u53ef\u4ee5\u5728\u8fd0\u884c\u65f6\u4ea7\u751f\u66f4\u4e30\u5bcc\u7684\u4f5c\u7528\u2014\u2014PEP 593 \u4e2d\u5c55\u793a\u4e86\u4e00\u4e2a\u7c7b\u4f3c\u7684\u4f8b\u5b50\u3002<\/p>\n<p>\u67e5\u770b PEP 593:<\/p>\n<p>https:\/\/www.python.org\/dev\/peps\/pep-0593\/#combining-runtime-and-static-uses-of-annotations<\/p>\n<h1><strong>\u88c5\u9970\u5668\u8bed\u6cd5\u66f4\u52a0\u7075\u6d3b<\/strong><\/h1>\n<p> <\/p>\n<p>\u65e7\u7248\u672c\u7684 Python \u5bf9\u88c5\u9970\u5668\u7684\u8bed\u6cd5\u6709\u6240\u9650\u5236\uff0cPython 3.9 \u5c06\u8fd9\u4e00\u9650\u5236\u653e\u5bbd\u2014\u2014\u4efb\u610f\u201c\u8868\u8fbe\u5f0f\u201d\u5747\u53ef\u7528\u5728\u88c5\u9970\u5668\u4e2d\u3002\u5982\u679c\u8bfb\u8005\u5bf9\u201c\u4efb\u610f\u8868\u8fbe\u5f0f\u201d\u8fd9\u4e00\u6982\u5ff5\u611f\u5230\u6a21\u7cca\uff0c\u53ef\u4ee5\u53c2\u8003 if \u6216 while \u8bed\u53e5\uff0c\u5728 Python 3.9 \u4e2d\uff0c\u4efb\u610f\u53ef\u4ee5\u7528\u5728 if \u6216 while \u6d4b\u8bd5\u90e8\u5206\u7684\u8bed\u53e5\u90fd\u53ef\u4ee5\u6210\u4e3a\u88c5\u9970\u5668\u800c\u4e0d\u4f1a\u4ea7\u751f\u8bed\u6cd5\u9519\u8bef\u3002\u5982\u4e0b\u56fe\u6240\u793a\uff0c\u751a\u81f3\u533f\u540d\u51fd\u6570\u4e5f\u53ef\u4ee5\u76f4\u63a5\u4f5c\u4e3a\u88c5\u9970\u5668\uff08\u867d\u7136\u56fe\u4e2d\u7684\u505a\u6cd5\u6beb\u65e0\u610f\u4e49\uff0c\u5728\u6b64\u4ec5\u4ec5\u4e3a\u4e86\u6f14\u793a\u8bed\u6cd5\u7279\u6027\uff09\uff0c\u5728 Python 3.8 \u6216\u4e4b\u524d\u7684\u7248\u672c\u4e2d\uff0c\u8fd9\u6837\u7684\u5199\u6cd5\u4f1a\u5f15\u53d1 SyntaxError \u3002<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" referrerpolicy=\"no-referrer\" rel=\"noreferrer\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2021\/04\/20210401_6065d65a28569.webp\" alt=\"\u6280\u672f\u63ed\u79d8 | Python 3.9 \u65b0\u7279\u6027\u901f\u89c8\" \/><\/p>\n<p>PEP-614 \u4e3a\u6211\u4eec\u5c55\u793a\u4e86\u4e00\u4e2a\u66f4\u6709\u5b9e\u7528\u4ef7\u503c\u7684\u4f8b\u5b50 \u2014\u2014 \u5728\u7f16\u5199 PyQt5 \u4ee3\u7801\u65f6\u4e3a\u6309\u94ae\u5217\u8868\u4e2d\u7684\u6bcf\u4e2a\u5143\u7d20\u5206\u522b\u6ce8\u518c\u4e8b\u4ef6\u3002<\/p>\n<p>\u67e5\u770b PEP 614:<\/p>\n<p>https:\/\/www.python.org\/dev\/peps\/pep-0614\/#motivation<\/p>\n<h1><strong>classmethod<\/strong> <strong>\u652f\u6301\u5305\u88c5\u5176\u4ed6\u63cf\u8ff0\u5668<\/strong><\/h1>\n<p> <\/p>\n<p>Python3.9 \u4e2d\u7684 classmethod \u51fd\u6570\u589e\u52a0\u4e86\u5bf9\u5305\u88c5\u5176\u4ed6\u63cf\u8ff0\u5668\uff08 descriptor \uff09\u7684\u652f\u6301\u3002\u5982\u4e0b\u56fe\u6240\u793a\uff0c\u73b0\u5728\u6211\u4eec\u53ef\u4ee5\u7ed3\u5408 classmethod \u548c property \u8f7b\u677e\u521b\u9020\u51fa\u4e00\u4e2a\u7c7b\u7684\u5c5e\u6027\uff08\u5728 3.8 \u53ca\u4e4b\u524d\u7684\u7248\u672c\u4e2d\uff0c\u5f00\u53d1\u8005\u9700\u8981\u624b\u5de5\u5b9e\u73b0\u4e00\u4e2a\u63cf\u8ff0\u5668\u4ee5\u652f\u6301\u7c7b\u4f3c\u7684\u529f\u80fd\uff09\u3002<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" referrerpolicy=\"no-referrer\" rel=\"noreferrer\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2021\/04\/20210401_6065d65dc45e3.png\" alt=\"\u6280\u672f\u63ed\u79d8 | Python 3.9 \u65b0\u7279\u6027\u901f\u89c8\" \/><\/p>\n<h1><strong>\u65b0\u589e\u6a21\u5757\u3001\u51fd\u6570\u3001\u65b9\u6cd5<\/strong><\/h1>\n<p> <\/p>\n<p>\u5305\u62ec\u4e14\u4e0d\u9650\u4e8e\uff1a<\/p>\n<ul>\n<li>\n<p>\u6807\u51c6\u5e93\u4e2d\u6dfb\u52a0\u4e86\u65f6\u533a\u6570\u636e\u5e93\u6a21\u5757 zoneinfo<\/p>\n<\/li>\n<li>\n<p>\u5185\u7f6e\u7684\u5b57\u7b26\u4e32\u7c7b\u578b\u52a0\u5165\u4e86\u65b0\u7684\u6390\u5934\u53bb\u5c3e\u65b9\u6cd5 removeprefix \u548c removesuffix<\/p>\n<\/li>\n<li>\n<p>math \u6a21\u5757\u4e2d\u65b0\u589e\u4e86\u591a\u4e2a\u6570\u5b66\u8fd0\u7b97\u51fd\u6570<\/p>\n<\/li>\n<\/ul>\n<h1><strong>\u53c2\u8003\u8d44\u6599<\/strong><\/h1>\n<p> <\/p>\n<p>1.Python.org<\/p>\n<p>2.Python Enhancement Proposals (PEPs)<\/p>\n<p>3.Python Documentation<\/p>\n<p>\u4e0a\u6587\u4e2d\u4ecb\u7ecd\u7684\u7279\u6027\u4ec5\u4ec5\u662f Python 3.9 \u66f4\u65b0\u4e2d\u7684\u51b0\u5c71\u4e00\u89d2\uff0c\u60f3\u8981\u66f4\u5168\u9762\u5730\u4e86\u89e3 Python 3.9\uff0c\u60a8\u53ef\u4ee5\uff1a<\/p>\n<ul>\n<li>\u76f4\u63a5\u8bbf\u95ee\u6587\u6863<\/li>\n<li>\u4e0b\u8f7d Python3.9 \u7684\u5b89\u88c5\u5668\u6216\u6e90\u7801\uff08 anaconda \u9891\u9053\u4e2d\u5c1a\u672a\u63d0\u4f9b Python 3.9 \uff09\u81ea\u884c\u4f53\u9a8c\u3002<\/li>\n<\/ul>\n<p><strong>\u6b22\u8fce\u8054\u7cfb\u7c73\u7b50\u91cf\u5316\u738b\u8001\u5e08\u5fae\u4fe1 RicequantCS \u6c9f\u901a\u5206\u4eab\u66f4\u591a\u91d1\u878d\u6280\u672f\u5e72\u8d27\uff0c\u4e5f\u6b22\u8fce\u5927\u5bb6\u8fdb\u884c\u91cf\u5316\u4ea7\u54c1\u8bd5\u7528\u3002<\/strong><\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>0<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u6280\u672f\u63ed\u79d8 | Python 3.9&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/419759"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=419759"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/419759\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=419759"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=419759"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=419759"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}