{"id":2249,"date":"2018-08-13T13:45:18","date_gmt":"2020-02-12T13:58:42","guid":{"rendered":"http:\/\/vip.fxxkpython.com\/?p=2249"},"modified":"2020-02-12T21:58:43","modified_gmt":"2020-02-12T13:58:43","slug":"06d32606f7","status":"publish","type":"post","link":"https:\/\/vip.fxxkpython.com\/?p=2249","title":{"rendered":"\u628a\u4f60\u7684\u201c\u5973\u670b\u53cb\u201d\u5b58\u50a8\u8d77\u6765"},"content":{"rendered":"<div class=\"bpp-post-content\">\n<p style=\"text-align: justify;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\" ><img decoding=\"async\" class=\"mpa-image aligncenter\"    style=\"width: 17%;height: auto !important;\" src=\"http:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2020\/02\/python7-1581515923.jpeg\" alt=\"python\" title=\"python\"  \/>&nbsp;<span style=\"color: rgb(136, 136, 136);font-size: 14px;\">\u4f60\u597d\uff0c\u6211\u662f\u5feb\u9012\u5458\uff0c\u4f60\u7684\u5973\u670b\u53cb\u5230\u4e86\uff0c\u8bf7\u7b7e\u6536\u4e00\u4e0b\u3002<\/span><\/p>\n<p style=\"text-align: justify;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\"><br  \/><\/p>\n<p style=\"text-align: justify;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\"><br  \/><\/p>\n<p style=\"text-align: right;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\"><span style=\"color: rgb(136, 136, 136);font-size: 14px;\">\u54c7\uff01\u597d\u54a7<\/span>\u3002<img decoding=\"async\" class=\"mpa-image aligncenter\"    style=\"width: 18%;height: auto !important;\" src=\"http:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2020\/02\/python4-1581515923.png\" alt=\"python\" title=\"python\"  \/><\/p>\n<p style=\"text-align: right;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\"><br  \/><\/p>\n<p style=\"text-align: right;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\"><br  \/><\/p>\n<p style=\"text-align: left;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\"><img decoding=\"async\" class=\"mpa-image aligncenter\"    style=\"text-align: left;width: 17%;\" src=\"http:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2020\/02\/python9-1581515923.jpeg\" alt=\"python\" title=\"python\"  \/>&nbsp;<span style=\"color: rgb(136, 136, 136);font-size: 14px;\">\u8bf7\u6ce8\u610f\u536b\u751f\uff01<\/span><br  \/><\/p>\n<p style=\"text-align: left;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\"><br  \/><\/p>\n<p style=\"text-align: left;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\"><br  \/><\/p>\n<p style=\"text-align: left;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\">\u6628\u5929\u6211\u4eec\u5df2\u7ecf\u77e5\u9053\u4e86<a href=\"http:\/\/mp.weixin.qq.com\/s?__biz=MzU2ODYzNTkwMg==&amp;mid=2247483897&amp;idx=1&amp;sn=53d4e2861f4100fbf09b72e2940497cc&amp;chksm=fc8bb968cbfc307e5ed5d79fb2f6db0af645cff42684f733d2fff8ee8e44da34ec83c963dbcd&amp;scene=21#wechat_redirect\" target=\"_blank\">Python\u662f\u600e\u4e48\u8bfb\u5199\u5c0f\u9ec4\u6587\u7684\uff1f<\/a><\/p>\n<p style=\"text-align: left;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\"><br  \/><\/p>\n<p style=\"text-align: left;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\">\u63a5\u4e0b\u6765\u6211\u4eec\u6765\u4e86\u89e3\u4e00\u4e0b<strong>\u6587\u4ef6\u5b58\u50a8\u5668\u3002<\/strong><\/p>\n<p style=\"text-align: left;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\"><br  \/><\/p>\n<p style=\"text-align: left;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\">Python \u6709\u4e00\u4e2a\u53eb\u505a&nbsp;pickle \u7684\u6a21\u5757\uff0c\u6709\u4e86\u5b83\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5<strong>\u5728\u4e00\u4e2a\u6587\u4ef6\u4e2d<\/strong><strong>\u6301\u4e45<\/strong>\u7684\u5b58\u50a8\u6211\u4eec\u7684\u5973\u670b\u53cb\uff0c\u54e6\uff0c\u4e0d\u662f\uff0c\u53ef\u4ee5\u6301\u4e45\u7684\u5b58\u50a8\u6211\u4eec\u7684<strong>\u5bf9\u8c61<\/strong>\u3002<\/p>\n<p style=\"text-align: left;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\"><br  \/><\/p>\n<p style=\"text-align: left;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\">\u8fd8\u6709\u4e00\u4e2a\u53eb\u505a cPickle \u7684\u6a21\u5757\uff0c\u5b83\u662f\u7528 C \u5199\u7684\uff0c\u6240\u4ee5\u5b83\u66f4\u52a0\u725b\u903c\u4e00\u70b9\uff0c\u6bd4 pickle \u901f\u5ea6\u5feb\uff0c\u8981\u5feb\u4e0a 1000 \u500d\uff0c\u6240\u4ee5\u6211\u4e48\u7528 cPickle \u8fd9\u4e2a\u6a21\u5757\u4f1a\u597d\u70b9\u3002<\/p>\n<p style=\"text-align: left;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\"><br  \/><\/p>\n<p style=\"text-align: left;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\">\u4e0d\u8fc7\u5728 Python3 \u5df2\u7ecf\u5c06 cPickle \u6539\u540d\u4e3a pickle \u4e86\uff0c\u6240\u4ee5\u6211\u4eec\u5c31\u53ef\u4ee5\u76f4\u63a5 import pickle \u5c31\u53ef\u4ee5\u5566\u3002<\/p>\n<p style=\"text-align: left;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\"><br  \/><\/p>\n<p style=\"text-align: left;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\">\u5199\u4e2a\u6587\u4ef6\u5b58\u50a8\u5668\u7684\u4f8b\u5b50\uff1a<br  \/><\/p>\n<p style=\"text-align: left;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\"><br  \/><\/p>\n<pre style=\"background-color: rgb(43, 43, 43);color: rgb(169, 183, 198);font-family: \u5b8b\u4f53;font-size: 12pt;margin-left: 0.5em;margin-right: 0.5em;\"><span style=\"color:#cc7832;\">import <\/span>pickle <span style=\"color:#cc7832;\">as <\/span>p<br  \/><br  \/><br  \/><span style=\"color:#808080;\"># \u6211\u4eec\u8981\u5b58\u50a8\u5185\u5bb9\u7684\u6587\u4ef6\u540d<br  \/><\/span>girlfriendlistfile = <span style=\"color:#6a8759;\">'girlfriend.data'<br  \/><br  \/><\/span>girlfriends = [<span style=\"color:#6a8759;\">'\u6ce2\u591a\u91ce\u7ed3\u8863'<\/span><span style=\"color:#cc7832;\">, <\/span><span style=\"color:#6a8759;\">'\u82cd\u4e95\u7a7a'<\/span><span style=\"color:#cc7832;\">, <\/span><span style=\"color:#6a8759;\">'\u5c0f\u6cfd\u739b\u5229\u4e9a'<\/span>]<br  \/><br  \/><span style=\"color:#808080;\"># \u628a\u6211\u4eec\u7684\u5973\u670b\u53cb\u5199\u5230\u6587\u4ef6\u91cc\uff0c\u7136\u540e\u5b58\u50a8\u5668\u5b58\u50a8<br  \/><\/span><span style=\"color:#cc7832;\">with <\/span><span style=\"color:#8888c6;\">open<\/span>(girlfriendlistfile<span style=\"color:#cc7832;\">,<\/span><span style=\"color:#6a8759;\">'wb+'<\/span>) <span style=\"color:#cc7832;\">as <\/span>f:<br  \/>    p.dump(girlfriends<span style=\"color:#cc7832;\">, <\/span>f) <span style=\"color:#808080;\"><br  \/> &nbsp; &nbsp;<\/span>f.close()<br  \/><br  \/><span style=\"color:#cc7832;\">del <\/span>girlfriends <span style=\"color:#808080;\"># \u5220\u6389\u6211\u4eec\u7684\u5973\u670b\u53cb<br  \/><br  \/># \u628a\u6211\u4eec\u7684\u5973\u670b\u53cb\u8bfb\u56de\u6765\uff01\uff01<br  \/><\/span><span style=\"color:#cc7832;\">with <\/span><span style=\"color:#8888c6;\">open<\/span>(girlfriendlistfile<span style=\"color:#cc7832;\">,<\/span><span style=\"color:#6a8759;\">'rb+'<\/span>) <span style=\"color:#cc7832;\">as <\/span>f:<br  \/>    list = p.load(f)<br  \/>    <span style=\"color:#8888c6;\">print <\/span>(list)<\/pre>\n<p style=\"text-align: left;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\"><br  \/><\/p>\n<p style=\"text-align: left;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\">\u8fd9\u5c31\u662f\u5b58\u50a8\u5668\u7684\u4f7f\u7528\uff0c\u662f\u4e0d\u662fso easy\uff1f<\/p>\n<p style=\"text-align: left;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\"><br  \/><\/p>\n<p style=\"text-align: left;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\">\u5bf9\u4e86\uff0c\u544a\u8bc9\u5927\u5bb6\u4e00\u4ef6\u4e8b\uff01\uff01<\/p>\n<p style=\"text-align: left;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\">\u6211\u5f88\u6c14\u6c1b\uff01\uff01<\/p>\n<p style=\"text-align: left;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\"><br  \/><\/p>\n<p style=\"text-align: left;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\"><span style=\"font-size: 14px;color: rgb(136, 136, 136);\">\u5fae\u4fe1\u91cc\u7684\u67d0\u4e2a\u4eba\uff0c\u505a\u4eba\u522b\u592a\u8fc7\u5206\u4e86\uff0c\u771f\u7684\uff0c\u6211\u4e0d\u60f3\u9a82\u4eba\uff0c\u4f60\u5728\u80cc\u540e\u8fd9\u4e48\u8bf4\u6211\uff0c\u5982\u679c\u4e0d\u662f\u522b\u4eba\u8dd1\u6765\u4eb2\u53e3\u8ddf\u6211\u8bf4\uff0c\u6211\u8fd8\u771f\u4e0d\u77e5\u9053\u4f60\u8fd9\u4e48\u591a\u5634\uff0c\u505a\u4e8b\u771f\u7684\u4e0d\u8981\u592a\u8fc7\u5206\uff0c\u6362\u4f4d\u601d\u8003\u4e0b\u5982\u679c\u6211\u4e5f\u8fd9\u4e48\u8bf4\u4f60\u4f60\u4f1a\u600e\u4e48\u60f3\uff0c\u8bdd\u6211\u6482\u8fd9\u513f\u4e86\uff0c\u6211\u628a\u4f60\u5f53\u597d\u670b\u53cb\uff0c\u6709\u4ec0\u4e48\u4e8b\u60c5\u548c\u4f60\u5206\u4eab\uff0c\u5475\u5475\u2026\u2026\u4f60\u5c45\u7136\u80cc\u540e\u8bf4\u6211\u957f\u7684\u5e05\uff0c\u8bf4\u6211\u6709\u624d\u534e\uff0c\u4eba\u53c8\u597d\u53c8\u4e13\u4e00\u53c8\u6d6a\u6f2b\uff0c\u4e03\u5915\u53c8\u5230\u4e86 \uff0c\u641e\u5f97\u73b0\u5728\u597d\u591a\u59b9\u5b50\u52a0\u6211 \uff0c\u5f04\u5f97\u6211\u73b0\u5728\u90fd\u5fd9\u4e0d\u8fc7\u6765\uff01\u4f60\u89c9\u5f97\u8fd9\u6837\u6709\u610f\u601d\u5417\uff1f<\/span><\/p>\n<p style=\"text-align: left;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\"><span style=\"font-size: 14px;color: rgb(136, 136, 136);\"><br  \/><\/span><\/p>\n<p style=\"text-align: left;margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;\"><span style=\"font-size: 14px;color: rgb(136, 136, 136);\"><br  \/><\/span><\/p>\n<p style=\"margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;text-align: center;\"><span style=\"letter-spacing: 3px;text-align: center;\">\u5173\u6ce8\u6211\uff0c\u8ba9\u4f60\u50cf\u770b\u5c0f\u9ec4\u6587\u4e00\u6837\u8f7b\u677e\u5b66\u5230 Python \u7684\u6240\u6709\uff01<\/span><\/p>\n<p style=\"margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;text-align: justify;\"><br  \/><\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" class=\" aligncenter\"       style=\"width: 69%;height: auto !important;box-shadow: rgb(170, 170, 170) 0em 0em 1em 0px;\" src=\"http:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2020\/02\/python10-1581515923.jpeg\" alt=\"python\" title=\"python\"  \/><\/p>\n<p style=\"margin-left: 0.5em;margin-right: 0.5em;letter-spacing: 3px;text-align: justify;\"><br  \/><\/p>\n<p style=\"margin-right: 0.5em;margin-left: 0.5em;white-space: normal;letter-spacing: 3px;text-align: center;\"><br  \/><\/p>\n<p style=\"margin-right: 0.5em;margin-left: 0.5em;white-space: normal;letter-spacing: 3px;text-align: justify;\"><br  \/><\/p>\n<p style=\"margin-right: 0.5em;margin-left: 0.5em;white-space: normal;letter-spacing: 3px;text-align: justify;\"><br  \/><\/p>\n<p style=\"margin-right: 0.5em;margin-left: 0.5em;white-space: normal;text-align: justify;letter-spacing: 3px;\">ps\uff1a\u8fd8\u6ca1\u83b7\u53d6\u6211\u7cbe\u5fc3\u51c6\u5907\u7684 Python \u7535\u5b50\u4e66\u548c\u601d\u7ef4\u5bfc\u56fe\u7b49\u5e72\u8d27\u7684\u53ef\u4ee5\u5728\u6211\u7684\u516c\u4f17\u53f7\u300c\u5b66\u4e60Python\u7684\u6b63\u786e\u59ff\u52bf\u300d\u4e2d\u53d1\u9001 python \u514d\u8d39\u83b7\u53d6\u54e6\uff01&nbsp;<\/p>\n<p style=\"margin-right: 0.5em;margin-left: 0.5em;white-space: normal;text-align: justify;letter-spacing: 3px;\">&nbsp;&nbsp;&nbsp;<\/p>\n<p style=\"margin-right: 0.5em;margin-left: 0.5em;white-space: normal;text-align: justify;letter-spacing: 3px;\"><strong>\u518dps:\u8bf4\u771f\u7684\uff0c\u5982\u679c\u4f60\u80fd\u70b9\u4e2a\u8d5e\u8f6c\u53d1\u652f\u6301\u6211\u4e00\u4e0b\u6211\u4f1a\u66f4\u6709\u52a8\u529b\u5199\u3002<\/strong><\/p>\n<p style=\"margin-right: 0.5em;margin-left: 0.5em;white-space: normal;text-align: right;letter-spacing: 3px;\"><strong><br  \/><\/strong><\/p>\n<p style=\"margin-right: 0.5em;margin-left: 0.5em;white-space: normal;text-align: right;letter-spacing: 3px;\"><br  \/><\/p>\n<p style=\"margin-right: 0.5em;margin-left: 0.5em;white-space: normal;letter-spacing: 3px;text-align: right;\"><span style=\"text-align: justify;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong style=\"text-align: right;\"><img decoding=\"async\" class=\"mpa-image aligncenter\"     src=\"http:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2020\/02\/python4-1581515923.gif\" alt=\"python\" title=\"python\"  \/><\/strong><\/span><\/p>\n<blockquote class=\"keep-source\">\n<p>\u539f\u6587\u59cb\u53d1\u4e8e\u5fae\u4fe1\u516c\u4f17\u53f7\uff08\u5b66\u4e60python\u7684\u6b63\u786e\u59ff\u52bf\uff09\uff1a<a target=\"_blank\" href=\"http:\/\/mp.weixin.qq.com\/s?__biz=MzU2ODYzNTkwMg==&#038;mid=2247483901&#038;idx=1&#038;sn=c5727c9bc9622b3f1385295d4fd397f5&#038;chksm=fc8bb96ccbfc307af938331d80e113176b84622632f3fd8c85bd7aa8dd9752281c44590c2408\">python<\/a><\/p>\n<\/blockquote>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp;\u4f60\u597d\uff0c\u6211\u662f\u5feb\u9012\u5458\uff0c\u4f60\u7684\u5973\u670b\u53cb\u5230\u4e86\uff0c\u8bf7\u7b7e\u6536\u4e00\u4e0b\u3002 \u54c7\uff01\u597d\u54a7\u3002 &nbsp;\u8bf7\u6ce8\u610f\u536b\u751f\uff01 \u6628\u5929\u6211\u4eec\u5df2\u7ecf\u77e5\u9053\u4e86Python\u662f\u600e\u4e48\u8bfb\u5199\u5c0f\u9ec4\u6587\u7684\uff1f \u63a5\u4e0b\u6765\u6211\u4eec\u6765\u4e86\u89e3\u4e00\u4e0b\u6587\u4ef6\u5b58\u50a8\u5668\u3002 Python \u6709\u4e00\u4e2a\u53eb\u505a&nbsp;pickle \u7684\u6a21\u5757\uff0c\u6709\u4e86\u5b83\uff0c&hellip;<\/p>\n","protected":false},"author":1,"featured_media":2250,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[303],"tags":[302,19,300,301],"_links":{"self":[{"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/posts\/2249"}],"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=2249"}],"version-history":[{"count":1,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/posts\/2249\/revisions"}],"predecessor-version":[{"id":2256,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/posts\/2249\/revisions\/2256"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/media\/2250"}],"wp:attachment":[{"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2249"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2249"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2249"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}