{"id":1235,"date":"2019-12-06T15:55:54","date_gmt":"2019-12-06T07:55:54","guid":{"rendered":"http:\/\/vip.fxxkpython.com\/?p=1235"},"modified":"2019-12-06T15:55:54","modified_gmt":"2019-12-06T07:55:54","slug":"python-%e7%88%ac%e9%98%b6%e6%a2%af-%e5%8d%8f%e7%a8%8b%e5%9c%a8%e6%89%8b%ef%bc%8c%e8%af%b4%e8%b5%b0%e5%b0%b1%e8%b5%b0","status":"publish","type":"post","link":"https:\/\/vip.fxxkpython.com\/?p=1235","title":{"rendered":"Python \u722c\u9636\u68af | \u534f\u7a0b\u5728\u624b\uff0c\u8bf4\u8d70\u5c31\u8d70"},"content":{"rendered":"\n<p>\u4eca\u5929\u54b1\u4eec\u6765\u5b66\u4e60\u5982\u4f55\u901a\u8fc7 Python \u6765\u4f7f\u7528\u534f\u7a0b\uff0c\u6211\u4eec\u4e4b\u524d\u8bf4\u8fc7\uff0c\u534f\u7a0b\u4e5f\u662f\u4e00\u79cd\u5b9e\u73b0\u5e76\u53d1\u7684\u624b\u6bb5\uff0c\u5b83\u7684\u4e00\u4e2a\u4e3b\u8981\u7684\u7279\u70b9\u5c31\u662f\uff0c\u5f02\u6b65\u4efb\u52a1\u7684\u8c03\u5ea6\u53ef\u4ee5\u7531\u6211\u4eec\u81ea\u5df1\u51b3\u5b9a\u3002<\/p>\n\n\n\n<p>\u5728 Python3.7 \u4e2d\uff0c\u63d0\u4f9b\u4e86 asyncio \u6a21\u5757\uff0c\u4f7f\u7528\u5b83\u53ef\u4ee5\u6765\u5b9e\u73b0\u4e00\u4e2a\u534f\u7a0b\u7684\u7a0b\u5e8f\u3002<\/p>\n\n\n\n<p>\u522b\u61f5\u903c\uff0c\u54b1\u4eec\u7528\u4ee3\u7801\u8bf4\u8bdd\uff0c\u5c31\u4f1a\u5bb9\u6613\u7406\u89e3\u4e00\u4e9b\u4e86\u3002<\/p>\n\n\n\n<p>\u5148\u6765\u770b\u770b\u8fd9\u4e48\u4e00\u4e2a\u7b80\u5355\u7684\u4ee3\u7801\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" width=\"342\" height=\"254\" src=\"https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2019\/12\/Screenshot-from-2019-12-02-17-53-37.png\" alt=\"\" class=\"wp-image-1236\" srcset=\"https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2019\/12\/Screenshot-from-2019-12-02-17-53-37.png 342w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2019\/12\/Screenshot-from-2019-12-02-17-53-37-300x223.png 300w\" sizes=\"(max-width: 342px) 100vw, 342px\" \/><\/figure><\/div>\n\n\n\n<p>\u5728\u8fd9\u91cc\u6211\u4eec\u5b9a\u4e49\u4e86\u4e00\u4e2a main \u65b9\u6cd5\uff0c\u6bcf\u9694\u4e00\u79d2\u949f\u5c31\u6253\u5370\u4e00\u53e5\u8bdd\uff0c\u7136\u540e\u8bb0\u5f55\u4e00\u4e0b\u6267\u884c\u7684\u65f6\u95f4\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" width=\"276\" height=\"303\" src=\"https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2019\/12\/Screenshot-from-2019-12-02-18-29-54.png\" alt=\"\" class=\"wp-image-1237\" srcset=\"https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2019\/12\/Screenshot-from-2019-12-02-18-29-54.png 276w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2019\/12\/Screenshot-from-2019-12-02-18-29-54-273x300.png 273w\" sizes=\"(max-width: 276px) 100vw, 276px\" \/><\/figure><\/div>\n\n\n\n<p>\u63a5\u4e0b\u6765\u6211\u4eec\u7ed9\u8fd9\u6bb5\u4ee3\u7801\u52a0\u4e0a\u534f\u7a0b\uff1a<div style=\"text-align:center;border:1px dashed #FF9A9A;padding:8px;margin:10px auto;color:#FF6666;\">\u672c\u6587\u9690\u85cf\u5185\u5bb9 <a href=\"https:\/\/vip.fxxkpython.com\/wp-login.php?redirect_to=https%3A%2F%2Fvip.fxxkpython.com%2F%3Fp%3D1235\">\u767b\u9646<\/a> \u540e\u624d\u53ef\u4ee5\u6d4f\u89c8<\/div>\u7ed3\u679c\u5f88\u660e\u663e\uff0c1\u79d2\u5c31\u641e\u5b9a\u4e86\u3002\u503c\u5f97\u6ce8\u610f\u7684\u662f\uff0c\u8fd9\u91cc\u7684 \u201c\u5e05b\u8001\u4ed9\u201d \u662f\u5728\u4f60 main \u51fd\u6570\u7684 await asyncio.sleep(1) \u4e4b\u524d\uff0c\u6240\u4ee5\u6bcf\u4e00\u4e2a\u4efb\u52a1\u6267\u884c\u5230\u8fd9\u91cc\u7684\u65f6\u5019\uff0c\u9047\u5230 await \u5c31\u4f1a\u7684\u5f53\u524d\u4efb\u52a1\u5c31\u4f1a\u8df3\u51fa\uff0c\u5f00\u59cb\u8c03\u5ea6\u4e0b\u4e00\u4e2a\u4efb\u52a1\uff0c 1 \u79d2\u949f\u8fc7\u540e\uff0c\u4e8b\u4ef6\u8c03\u5ea6\u5668\u5c31\u4f1a\u91cd\u65b0\u8c03\u5ea6\u4e00\u5f00\u59cb\u7684\u4efb\u52a1\uff0c\u5f80\u4e0b\u6267\u884c \u201c\u6cd5\u529b\u65e0\u8fb9\u201d\u3002<\/p>\n\n\n\n<p>\u901a\u8fc7\u534f\u7a0b\u7684\u65b9\u5f0f\uff0c\u53ef\u4ee5\u6709\u6548\u7684\u53bb\u9ad8\u6548\u7684\u6267\u884c\u5e76\u53d1\u4efb\u52a1\uff0c\u901a\u8fc7 asyncio \u6a21\u5757\u7684 await \u548c create_task \u65b9\u5f0f\u6765\u6709\u6548\u63a7\u5236\u4efb\u52a1\u7684\u5207\u6362\u3002<\/p>\n\n\n\n<p>\u4ee5\u4e0a\u5c31\u662f Python \u4e2d\u4f7f\u7528\u534f\u7a0b\u7684\u65b9\u5f0f\uff0c\u8fd9\u91cc\u6f14\u793a\u7528\u5230\u7684 asyncio \u65b0\u65b9\u6cd5\uff0c\u9700\u8981\u4f60\u5347\u7ea7\u5230 3.7 \u4ee5\u4e0a\u7684\u7248\u672c\u624d\u80fd\u4f7f\u7528\u3002<\/p>\n\n\n\n<p>\u90a3\u4e48\u73b0\u5728\u7684\u4f60\uff0c\u662f\u5426\u53ef\u4ee5\u901a\u8fc7\u534f\u7a0b\u7684\u65b9\u5f0f\uff0c\u6539\u5199\u6211\u4eec\u4e0a\u6b21\u8bf4\u5230\u7684\u9ad8\u6548\u722c\u53d6\u8c46\u74e3 TOP250 \u7535\u5f71\uff1f<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u5929\u54b1\u4eec\u6765\u5b66\u4e60\u5982\u4f55\u901a\u8fc7 Python \u6765\u4f7f\u7528\u534f\u7a0b\uff0c\u6211\u4eec\u4e4b\u524d\u8bf4\u8fc7\uff0c\u534f\u7a0b\u4e5f\u662f\u4e00\u79cd\u5b9e\u73b0\u5e76\u53d1\u7684\u624b\u6bb5\uff0c\u5b83\u7684\u4e00\u4e2a\u4e3b\u8981\u7684\u7279\u70b9\u5c31\u662f\uff0c\u5f02\u6b65\u4efb\u52a1\u7684\u8c03\u5ea6\u53ef\u4ee5\u7531\u6211\u4eec\u81ea\u5df1\u51b3\u5b9a\u3002 \u5728 Python3.7 \u4e2d\uff0c\u63d0\u4f9b\u4e86 asyncio \u6a21\u5757\uff0c\u4f7f\u7528\u5b83\u53ef\u4ee5\u6765\u5b9e\u73b0\u4e00\u4e2a\u534f\u7a0b\u7684\u7a0b\u5e8f\u3002 \u522b\u61f5\u903c&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[140],"tags":[210,211,141,212,204,62,183,209,185],"_links":{"self":[{"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/posts\/1235"}],"collection":[{"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1235"}],"version-history":[{"count":1,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/posts\/1235\/revisions"}],"predecessor-version":[{"id":1265,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/posts\/1235\/revisions\/1265"}],"wp:attachment":[{"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1235"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1235"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1235"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}