{"id":206,"date":"2016-04-26T16:42:20","date_gmt":"2016-04-26T08:42:20","guid":{"rendered":"http:\/\/www.5x44.cn\/?p=206"},"modified":"2016-04-26T16:42:20","modified_gmt":"2016-04-26T08:42:20","slug":"%e7%ac%ac13%e7%ab%a0-%e5%ba%8f%e5%88%97%e5%8c%96python%e5%af%b9%e8%b1%a1","status":"publish","type":"post","link":"https:\/\/www.5x44.cn\/?p=206","title":{"rendered":"\u7b2c13\u7ae0 \u5e8f\u5217\u5316python\u5bf9\u8c61"},"content":{"rendered":"<h2>\uff081\uff09pickle\u6a21\u5757<\/h2>\n<p>pickle\u6a21\u5757\u53ef\u4ee5\u5b58\u50a8\u54ea\u4e9b\u7c7b\u578b\uff1f<\/p>\n<ul>\n<li>python\u652f\u6301\u7684\u6240\u6709\u672c\u5730\u6570\u636e\u7c7b\u578b\uff1abooleans, intergers, floating point numbers, complex numbers, strings, bytes objects, byte arrays, and None.<\/li>\n<li>\u6240\u6709\u672c\u5730\u590d\u5408\u7c7b\u578b\uff1alist, tuples, dictionaries, sets containing<\/li>\n<li>\u5404\u79cd\u672c\u5730\u57fa\u672c\u7c7b\u578b\u548c\u590d\u5408\u7c7b\u578b\u7684\u7ec4\u5408\uff08\u6df1\u5ea6\u76f4\u5230python\u6240\u652f\u6301\u7684\u6700\u5927\u503c<tt class=\"descclassname\">sys.<\/tt><tt class=\"descname\">getrecursionlimit<\/tt><big>(<\/big><big>)<\/big>\uff09<\/li>\n<li>\u51fd\u6570\u3001\u7c7b\u548c\u7c7b\u7684\u5b9e\u4f8b\uff08\u4f1a\u6709\u8b66\u544a\uff09<\/li>\n<\/ul>\n<h2>\uff082\uff09pickle\u6a21\u5757\u4fdd\u5b58\u6570\u636e<\/h2>\n<p><code> &gt;&gt;&gt; entry = {} <\/code><br \/>\n<code>&gt;&gt;&gt; entry['title'] = 'Dive into history, 2009 edition'<\/code><br \/>\n<code>&gt;&gt;&gt; entry['article_link'] = 'http:\/\/diveintomark.org\/archives\/2009\/03\/27\/dive-into-history-2009-edition'<\/code><br \/>\n<code>&gt;&gt;&gt; entry['comments_link'] = None<\/code><br \/>\n<code>&gt;&gt;&gt; entry['internal_id'] = b'\\xDE\\xD5\\xB4\\xF8'<\/code><br \/>\n<code>&gt;&gt;&gt; entry['tags'] = ('diveintopython', 'docbook', 'html')<\/code><br \/>\n<code>&gt;&gt;&gt; entry['published'] = True<\/code><br \/>\n<code>&gt;&gt;&gt; import time<\/code><br \/>\n<code>&gt;&gt;&gt; entry['published_date'] = time.strptime('Fri Mar 27 22:20:42 2009') <\/code><br \/>\n<code>&gt;&gt;&gt; entry['published_date']<\/code><br \/>\n<code>time.struct_time(tm_year=2009, tm_mon=3, tm_mday=27, tm_hour=22, tm_min=20, tm_sec=42, tm_wday=4, tm_yday=86, tm_isdst=-1)<\/code><\/p>\n<p><code> &gt;&gt;&gt; import pickle\u00a0\u00a0\u00a0\u00a0\u00a0 \u2460<\/code><br \/>\n<code>&gt;&gt;&gt; with open('entry.pickle', 'wb') as f: \u2461<\/code><br \/>\n<code>...\u00a0\u00a0\u00a0 pickle.dump(entry, f) \u2462<\/code><\/p>\n<ol>\n<li>\u5bfc\u5165pickle\u6a21\u5757<\/li>\n<li>\u4ee5\u4e8c\u8fdb\u5236\u65b9\u5f0f\u6253\u5f00\u4e00\u4e2a\u6587\u4ef6\uff0c\u6d41\u5bf9\u8c61\u4e3af<\/li>\n<li>pickle\u6a21\u5757\u4e2ddump()\u51fd\u6570\u8d1f\u8d23\u5e8f\u5217\u5316\u6570\u636e\u7ed3\u6784\uff0c\u5c06\u6570\u636e\u7ed3\u6784\u5e8f\u5217\u5316\u6210\u4e8c\u8fdb\u5236python\u6307\u5b9a\u7684\u683c\u5f0f\uff0c\u8fd9\u4e2a\u683c\u5f0f\u4f7f\u7528\u6700\u65b0\u7684pickle\u534f\u8bae\u7248\u672c\uff0c\u7136\u540e\u4fdd\u5b58\u5230\u6253\u5f00\u7684\u6587\u4ef6\u3002<\/li>\n<\/ol>\n<p>\u6700\u540e\u4e00\u53e5\u5f88\u91cd\u8981\uff1a<\/p>\n<ul>\n<li>pickle\u6a21\u5757\u628apython\u6570\u636e\u7ed3\u6784\u4fdd\u5b58\u5230\u4e00\u4e2a\u6587\u4ef6\u3002<\/li>\n<li>\u4f7f\u7528pickle\u534f\u8bae\u5e8f\u5217\u5316\u6570\u636e\u7ed3\u6784<\/li>\n<li>pickle\u534f\u8bae\u662fpython\u6307\u5b9a\u7684\uff0c\u4e0d\u4fdd\u8bc1\u5176\u5b83\u7684\u8bed\u8a00\u53ef\u4ee5\u8bfb\u53d6\u3002<\/li>\n<li>\u5e76\u4e0d\u662f\u6240\u6709\u7684python\u6570\u636e\u7ed3\u6784\u90fd\u53ef\u4ee5\u5e8f\u5217\u5316\u3002\u867d\u7136pickle\u534f\u8bae\u5df2\u7ecf\u66f4\u6539\u8fc7\u51e0\u6b21\uff0c\u6bcf\u6b21\u90fd\u662f\u56e0\u4e3a\u6709\u65b0\u7684\u6570\u636e\u7c7b\u578b\u52a0\u5165python\uff0c\u4f46\u8fd9\u4ecd\u7136\u662f\u9650\u5236\u3002<\/li>\n<li>\u5e8f\u5217\u5316\u7ed3\u679c\u5e76\u4e0d\u4fdd\u8bc1\u6bcf\u4e2apython\u7248\u672c\u90fd\u80fd\u8bfb\u53d6\u3002\u65b0\u7248\u672c\u53ef\u4ee5\u652f\u6301\u65e7\u7248\u672c\uff0c\u4f46\u65e7\u7248\u672c\u53ef\u80fd\u65e0\u6cd5\u89e3\u91ca\u65b0\u7248\u672c\uff08\u56e0\u4e3a\u4e0d\u652f\u6301\u65b0\u7684\u6570\u636e\u7c7b\u578b\uff09<\/li>\n<li>\u9664\u975e\u6307\u5b9apickle\u534f\u8bae\u7248\u672c\u53f7\uff0c\u4e0d\u7136\u4f1a\u9ed8\u8ba4\u4f7f\u7528\u6700\u65b0\u7684\u3002<\/li>\n<li>\u786e\u5b9a\u4ee5\u4e8c\u8fdb\u5236\u65b9\u5f0f\u6253\u5f00\u6587\u4ef6\uff0c\u4e0d\u7136\u5199\u5165\u5e8f\u5217\u5316\u65f6\u4f1a\u51fa\u9519\u3002<\/li>\n<\/ul>\n<h2>\uff083\uff09\u4ecepickle\u6587\u4ef6\u4e2d\u53d6\u56de\u6570\u636e<\/h2>\n<p><code> &gt;&gt;&gt; import pickle<\/code><br \/>\n<code>&gt;&gt;&gt; with open('entry.pickle', 'rb') as f: \u2460<\/code><br \/>\n<code>... \u00a0 \u00a0 entry = pickle.load(f)\u00a0\u00a0 \u2461<\/code><br \/>\n<code>...<\/code><br \/>\n<code>&gt;&gt;&gt; entry <\/code><br \/>\n<code>{'comments_link': None,<\/code><br \/>\n<code>'internal_id': b'\\xDE\\xD5\\xB4\\xF8',<\/code><br \/>\n<code>'title': 'Dive into history, 2009 edition',<\/code><br \/>\n<code>'tags': ('diveintopython', 'docbook', 'html'),<\/code><br \/>\n<code>'article_link':<\/code><br \/>\n<code>'http:\/\/diveintomark.org\/archives\/2009\/03\/27\/dive-into-history-2009-edition',<\/code><br \/>\n<code>'published_date': time.struct_time(tm_year=2009, tm_mon=3, tm_mday=27, tm_hour=22, tm_min=20, tm_sec=42, tm_wday=4, tm_yday=86, tm_isdst=-1),<\/code><br \/>\n<code>'published': True}<\/code><\/p>\n<ol>\n<li>\u4f7f\u7528with\u8bed\u53e5\u4ee5\u4e8c\u8fdb\u5236\u65b9\u5f0f\u6253\u5f00pickle\u6587\u4ef6\uff0c\u6d41\u5bf9\u8c61\u662ff\u3002<\/li>\n<li>pickle.load()\u6709\u4e00\u4e2a\u6d41\u5bf9\u8c61\u53c2\u6570\uff0c\u4ece\u8fd9\u4e2a\u6d41\u4e2d\u8bfb\u53d6\u88ab\u5e8f\u5217\u5316\u7684\u6570\u636e\uff0c\u521b\u5efa\u4e00\u4e2a\u65b0\u7684python\u5bf9\u8c61\uff0c\u5728\u8fd9\u4e2a\u65b0\u5bf9\u8c61\u4e2d\u91cd\u5efa\u88ab\u5e8f\u5217\u5316\u7684\u6570\u636e\uff0c\u6700\u540e\u8fd4\u56de\u65b0\u5bf9\u8c61\u3002<\/li>\n<\/ol>\n<h2>\uff084\uff09pickling without a file<\/h2>\n<p>\u5e8f\u5217\u5316\u7684\u7ed3\u679c\u53ef\u4ee5\u4e0d\u4fdd\u5b58\u5230\u6587\u4ef6\u4e2d\uff0c\u800c\u4fdd\u5b58\u5230\u5185\u5b58\u4e2d\u3002<\/p>\n<p><code> &gt;&gt;&gt; b = pickle.dumps(entry) \u2460<\/code><br \/>\n<code>&gt;&gt;&gt; type(b) \u2461<\/code><br \/>\n<code>&lt;class 'bytes'&gt;<\/code><br \/>\n<code>&gt;&gt;&gt; entry3 = pickle.loads(b) \u2462<\/code><br \/>\n<code>&gt;&gt;&gt; entry3 == entry \u2463<\/code><br \/>\n<code>True<\/code><\/p>\n<ol>\n<li>pickle.dumps()\u51fd\u6570\uff08<strong>\u6ce8\u610f\u5728\u51fd\u6570\u540d\u7ed3\u5c3e\u7684s<\/strong>\uff09\u6267\u884c\u548cpickle.dump()\u4e00\u6837\u7684\u5e8f\u5217\u5316\u529f\u80fd\u3002\u4f46\u662f\u4e0d\u540c\u7684\u65f6\u5b83\u628a\u5e8f\u5217\u5316\u7ed3\u679c\u8fd4\u56de\uff0c\u800c\u4e0d\u662f\u5199\u5165\u786c\u76d8\u3002<\/li>\n<li>\u56e0\u4e3apickle\u534f\u8bae\u4f7f\u7528\u4e8c\u8fdb\u5236\u6570\u636e\u683c\u5f0f\uff0c\u6240\u4ee5pickle.dumps()\u51fd\u6570\u8fd4\u56debytes\u5bf9\u8c61\u3002<\/li>\n<li>pickle.loads\u51fd\u6570\uff08<strong>\u540c\u6837\u6ce8\u610f\u51fd\u6570\u540d\u7ed3\u5c3e\u7684s<\/strong>\uff09\u6267\u884c\u548cpickle.load()\u4e00\u6837\u7684\u6062\u590d\u529f\u80fd\uff0c\u4f46\u662f\u5b83\u7684\u53c2\u6570\u4e0d\u662f\u6d41\u5bf9\u8c61\uff0c\u800c\u662f\u4e00\u4e2a\u4fdd\u5b58\u4e86\u5e8f\u5217\u5316\u6570\u636e\u7684bytes\u5bf9\u8c61\u3002<\/li>\n<li>\u5f53\u7136\u548c\u5fc5\u7136\u7684\u7ed3\u679c\u2014\u2014\u5b83\u4eec\u662f\u4e00\u6837\u7684\u3002<\/li>\n<\/ol>\n<h2>\uff085\uff09\u5f80\u4e8b\u5fc5\u987b\u518d\u6b21\u56de\u9996\u2014\u2014BYTES\u548cSTRINGS<\/h2>\n<p>pickle\u534f\u8bae\u5df2\u7ecf\u5f00\u53d1\u51fa\u6765\u5f88\u591a\u5e74\u4e86\uff0c\u5c31\u50cfpython\u672c\u8eab\u4e00\u6837\u6210\u719f\u3002\u8fd9\u91cc\u6709\u56db\u79cd\u4e0d\u540c\u7684pickle\u534f\u8bae\u7248\u672c\u3002<\/p>\n<ul>\n<li>python 1.x\u6709\u4e24\u4e2apickle\u534f\u8bae\uff0c\u4e00\u4e2a\u662f\u57fa\u4e8e\u6587\u672c\u683c\u5f0f\u7684\u521d\u7248\u672c\u548c\u4e00\u4e2a\u4e8c\u8fdb\u5236\u683c\u5f0f\u7684\u7248\u672c1.<\/li>\n<li>python 2.3\u5f15\u5165\u4e86\u4e00\u4e2a\u65b0\u7684pickle\u534f\u8bae\u7248\u672c2\uff0c\u53ef\u4ee5\u5904\u7406\u7c7b\u5bf9\u8c61\u3002<\/li>\n<li>python 3.0\u4ecb\u7ecd\u4e86\u53e6\u4e00\u4e2apickle\u534f\u8bae\u7248\u672c3\uff0c\u589e\u52a0\u4e86\u5bf9bytes\u5bf9\u8c61\u548cbyte\u6570\u7ec4\u7684\u663e\u793a\u652f\u6301\u3002<\/li>\n<\/ul>\n<p>\u597d\u5427\uff01\u770b\u4e00\u4e0bbytes\u548cstrings\u4e4b\u524d\u7684\u4e0d\u540c\uff08\u539f\u6587\u6307\u51fa\u5982\u679c\u4e0d\u77e5\u9053\u7684\u8bdd\uff0c\u90a3\u8bf4\u660e\u6ca1\u4ed4\u7ec6\u770b\u4e4b\u524d\u7684\u5185\u5bb9\u3002\u3002\u3002\u597d\u5427\uff01\u7ffb\u8bd1\u4e86\u534a\u5929\u6211\u4e5f\u5fd8\u4e86\u4e4b\u524d\u600e\u4e48\u5199\u7684\u5566\uff01\u7b2c\u56db\u7ae0\u7b2c\u516d\u8282strings VS. BYTES\uff09\u3002<\/p>\n<h2>\uff086\uff09\u53ef\u4ee5\u8ba9\u5176\u5b83\u8bed\u8a00\u6253\u5f00python\u7684\u5e8f\u5217\u5316\u5bf9\u8c61\u2014\u2014JSON<\/h2>\n<p>JSON\u662f\u57fa\u4e8e\u6587\u672c\u7684\uff0c\u5e76\u4e14\u5927\u5c0f\u5199\u654f\u611f\u3002\u56e0\u4e3a\u662f\u57fa\u4e8e\u6587\u672c\u7684\uff0c\u6240\u4ee5\u6709\u7a7a\u683c\u7684\u95ee\u9898\uff0c\u5728\u6bcf\u4e2a\u503c\u4e4b\u95f4\u53ef\u4ee5\u6709\u591a\u4e2a\u7a7a\u683c\uff0c\u5728\u7f16\u89e3\u7801\u65f6JSON\u4f1a\u5ffd\u7565\u8fd9\u4e9b\u503c\u4e4b\u95f4\u7684\u7a7a\u683c\u3002\u8fd9\u53ef\u4ee5\u8ba9\u4f60\u4ee5\u9002\u5f53\u7684\u7f29\u8fdb\u65b9\u5f0f\u5728\u663e\u793a\u5668\u4e0a\u663e\u793a\u6570\u636e\u6216\u6253\u5370\u51fa\u6765\u3002JSON\u5fc5\u987b\u4ee5UNICODE\u7f16\u7801\u5b58\u50a8\uff08UTF-32,UTF-16\u6216UTF-8\uff09\u3002<\/p>\n<p>\u53ef\u4ee5\u4f7f\u7528JavaScript\u7684eval()\u51fd\u6570\u53bb\u201c\u89e3\u7801\u201dJSON\u5e8f\u5217\u5316\u6570\u636e\u3002<\/p>\n<p><code> &gt;&gt;&gt; basic_entry = {} \u2460<\/code><br \/>\n<code>&gt;&gt;&gt; basic_entry['id'] = 256<\/code><br \/>\n<code>&gt;&gt;&gt; basic_entry['title'] = 'Dive into history, 2009 edition'<\/code><br \/>\n<code>&gt;&gt;&gt; basic_entry['tags'] = ('diveintopython', 'docbook', 'html')<\/code><br \/>\n<code>&gt;&gt;&gt; basic_entry['published'] = True<\/code><br \/>\n<code>&gt;&gt;&gt; basic_entry['comments_link'] = None<\/code><br \/>\n<code>&gt;&gt;&gt; <strong>import json<\/strong><\/code><br \/>\n<code>&gt;&gt;&gt; with open('basic.json', mode='w', encoding='utf-8') as f: \u2461<\/code><br \/>\n<code>...\u00a0\u00a0\u00a0\u00a0 json.dump(basic_entry, f)\u00a0\u00a0 \u2462<\/code><\/p>\n<ol>\n<li>\u5efa\u7acb\u4e00\u4e2a\u65b0\u7684\u6570\u636e\u7ed3\u6784\uff08\u6784\u5efa\u4e00\u4e2a\u5b57\u5178\uff09<\/li>\n<li>\u56e0\u4e3aJSON\u662f\u57fa\u4e8e\u6587\u672c\u7684\uff0c\u4ee5\u5199\u6a21\u5f0f\u6253\u5f00\u4e00\u4e2a\u6587\u4ef6\uff0c\u7f16\u7801\u65b9\u5f0f\u662fUTF-8\u3002\uff08\u5c3d\u91cf\u4f7f\u7528UTF-8\uff0c\u8fd9\u4e0d\u4f1a\u6709\u4ec0\u4e48\u9519\u8bef\uff09<\/li>\n<li>\u5c31\u50cfpickle\u6a21\u5757\u4e00\u6837\uff0cJSON\u6a21\u5757\u4e5f\u5b9a\u4e49\u4e86dump()\u51fd\u6570\uff0c\u53c2\u6570\u662f\u4e00\u4e2apython\u6570\u636e\u7c7b\u578b\u548c\u4e00\u4e2a\u6d41\u5bf9\u8c61\u3002<\/li>\n<\/ol>\n<p>JSON\u5e8f\u5217\u5316\u540e\uff0c\u5b58\u50a8\u5728\u6587\u4ef6\u4e2d\u7684\u6570\u636e\u7ed3\u6784\u662f\u8fd9\u6837\u7684\uff1a<\/p>\n<p>{&#8220;published&#8221;: true, &#8220;tags&#8221;: [&#8220;diveintopython&#8221;, &#8220;docbook&#8221;, &#8220;html&#8221;], &#8220;comments_link&#8221;: null,<br \/>\n&#8220;id&#8221;: 256, &#8220;title&#8221;: &#8220;Dive into history, 2009 edition&#8221;}<\/p>\n<p><strong>\u4e3a\u66f4\u597d\u7684\u53bb\u9605\u8bfb\u53ef\u4ee5\u5728dump()\u51fd\u6570\u4e2d\u52a0\u5165indent\u53c2\u6570\uff1a<\/strong><\/p>\n<p><code> &gt;&gt;&gt; with open('basic-pretty.json', mode='w', encoding='utf-8') as f:<\/code><br \/>\n<code>...\u00a0\u00a0\u00a0\u00a0 json.dump(basic_entry, f, indent=2)<\/code><\/p>\n<ul>\n<li>indent\u53c2\u6570\u4f1a\u8ba9\u5e8f\u5217\u5316\u540e\u7684\u6570\u636e\u66f4\u5177\u53ef\u8bfb\u6027\uff0cindent\u4e3a0\u65f6\u8868\u793a\u201c\u6bcf\u4e2a\u503c\u5355\u72ec\u4e00\u884c\u201d\u3002\u5f53indent\u5927\u4e8e0\u65f6\u8868\u793a\u201c\u6bcf\u4e2a\u503c\u5355\u72ec\u4e00\u884c\uff0c\u5e76\u4e14\u6570\u636e\u7ed3\u6784\u7684\u7f29\u8fdb\u4f7f\u7528\u8fd9\u4e2a\u6570\u503c\u201d<\/li>\n<\/ul>\n<p><code> {<\/code><br \/>\n<code>\u00a0 \"published\": true,<\/code><br \/>\n<code>\u00a0 \"tags\": [<\/code><br \/>\n<code>\u00a0\u00a0\u00a0 \"diveintopython\",<\/code><br \/>\n<code>\u00a0\u00a0\u00a0 \"docbook\",<\/code><br \/>\n<code>\u00a0\u00a0\u00a0 \"html\"<\/code><br \/>\n<code>\u00a0 ],<\/code><br \/>\n<code>\u00a0 \"comments_link\": null,<\/code><br \/>\n<code>\u00a0 \"id\": 256,<\/code><br \/>\n<code>\u00a0 \"title\": \"Dive into history, 2009 edition\"<\/code><br \/>\n<code>}<\/code><\/p>\n<p><span style=\"text-decoration: underline;\"><span style=\"color: #ff0000; text-decoration: underline;\">JSON\u548cPYTHON3\u6570\u636e\u7c7b\u578b\u7684\u5bf9\u5e94\u5173\u7cfb\uff1a<\/span><\/span><\/p>\n<table style=\"height: 320px;\" border=\"1\" width=\"254\">\n<tbody>\n<tr>\n<th>\u6ce8\u610f<\/th>\n<th>JSON<\/th>\n<th>Python3<\/th>\n<\/tr>\n<tr>\n<th><\/th>\n<th>object<\/th>\n<th>directory<\/th>\n<\/tr>\n<tr>\n<th><\/th>\n<th>array<\/th>\n<th>list<\/th>\n<\/tr>\n<tr>\n<th><\/th>\n<th>string<\/th>\n<th>string<\/th>\n<\/tr>\n<tr>\n<th><\/th>\n<th>integer<\/th>\n<th>integer<\/th>\n<\/tr>\n<tr>\n<th><\/th>\n<th>\u5b9e\u9645\u6570\u5b57<\/th>\n<th>float<\/th>\n<\/tr>\n<tr>\n<th>*<\/th>\n<th>true<\/th>\n<th>True<\/th>\n<\/tr>\n<tr>\n<th>*<\/th>\n<th>false<\/th>\n<th>False<\/th>\n<\/tr>\n<tr>\n<th>*<\/th>\n<th>null<\/th>\n<th>None<\/th>\n<\/tr>\n<tr>\n<th colspan=\"3\">*\u8868\u793a\u6240\u6709JSON\u503c\u662f\u5927\u5c0f\u5199\u654f\u611f\u7684<\/th>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u4f60\u6ce8\u610f\u5230\u5c11\u4e86\u4ec0\u4e48\u5417\uff1fTuples\u548cbytes\uff01JSON\u6709\u4e00\u4e2aarray\u7c7b\u578b\uff0c\u5b83\u5728json\u6a21\u5757\u4e2d\u6620\u8bbe\u5230python\u7684list\uff0c\u4f46\u662f\u6ca1\u6709\u5355\u72ec\u7684\u7c7b\u578b\u6620\u5c04\u5230tuples\u3002\u5e76\u4e14JSON\u5bf9\u5b57\u7b26\u4e32\u7684\u652f\u6301\u5341\u5206\u597d\uff0c\u6240\u4ee5\u4e5f\u6ca1\u6709\u5355\u72ec\u652f\u6301bytes\u5bf9\u8c61\u548cbyte\u6570\u7ec4\u3002<\/p>\n<h2>\uff087\uff09\u5e8f\u5217\u5316JSON\u4e0d\u652f\u6301\u7684\u6570\u636e\u7c7b\u578b<\/h2>\n<p>\u5e8f\u5217\u5316JSON\u4e0d\u652f\u6301\u7684\u6570\u636e\u7c7b\u578b\uff0c\u9700\u8981\u63d0\u4f9b\u7f16\u89e3\u7801\u4e60\u60ef\u3002<\/p>\n<p><code> &gt;&gt;&gt; entry \u2460<\/code><br \/>\n<code>{'comments_link': None,<\/code><br \/>\n<code>'internal_id': b'\\xDE\\xD5\\xB4\\xF8',<\/code><br \/>\n<code>'title': 'Dive into history, 2009 edition',<\/code><br \/>\n<code>'tags': ('diveintopython', 'docbook', 'html'),<\/code><br \/>\n<code>'article_link': 'http:\/\/diveintomark.org\/archives\/2009\/03\/27\/dive-into-history-2009-edition',<\/code><br \/>\n<code>'published_date': time.struct_time(tm_year=2009, tm_mon=3, tm_mday=27, tm_hour=22, tm_min=20, tm_sec=42, tm_wday=4, tm_yday=86, tm_isdst=-1),<\/code><br \/>\n<code>'published': True}<\/code><br \/>\n<code>&gt;&gt;&gt; import json<\/code><br \/>\n<code>&gt;&gt;&gt; with open('entry.json', 'w', encoding='utf-8') as f: \u2461<\/code><br \/>\n<code>...\u00a0\u00a0\u00a0\u00a0 json.dump(entry, f) \u2462<\/code><br \/>\n<code>...<\/code><br \/>\n<span style=\"color: #993300;\"><code>Traceback (most recent call last):<\/code><\/span><br \/>\n<span style=\"color: #993300;\"><code>File \"&lt;stdin&gt;\", line 5, in &lt;module&gt;<\/code><\/span><br \/>\n<span style=\"color: #993300;\"><code>File \"C:\\Python31\\lib\\json\\__init__.py\", line 178, in dump<\/code><\/span><br \/>\n<span style=\"color: #993300;\"><code>for chunk in iterable:<\/code><\/span><br \/>\n<span style=\"color: #993300;\"><code>File \"C:\\Python31\\lib\\json\\encoder.py\", line 408, in _iterencode<\/code><\/span><br \/>\n<span style=\"color: #993300;\"><code>for chunk in _iterencode_dict(o, _current_indent_level):<\/code><\/span><br \/>\n<span style=\"color: #993300;\"><code>File \"C:\\Python31\\lib\\json\\encoder.py\", line 382, in _iterencode_dict<\/code><\/span><br \/>\n<span style=\"color: #993300;\"><code>for chunk in chunks:<\/code><\/span><br \/>\n<span style=\"color: #993300;\"><code>File \"C:\\Python31\\lib\\json\\encoder.py\", line 416, in _iterencode<\/code><\/span><br \/>\n<span style=\"color: #993300;\"><code>o = _default(o)<\/code><\/span><br \/>\n<span style=\"color: #993300;\"><code>File \"C:\\Python31\\lib\\json\\encoder.py\", line 170, in default<\/code><\/span><br \/>\n<span style=\"color: #993300;\"><code>raise TypeError(repr(o) + \" is not JSON serializable\")<\/code><\/span><br \/>\n<span style=\"text-decoration: underline;\"><span style=\"color: #993300;\"><code>TypeError: b'\\xDE\\xD5\\xB4\\xF8' is not JSON serializable<\/code><\/span><\/span><\/p>\n<ol>\n<li>\u91cd\u65b0\u770b\u4e00\u4e0b\u8fd9\u4e2a\u6570\u636e\u7ed3\u6784\uff0c\u91cc\u9762\u6709\u4e00\u4e2abytes\u7c7b\u578b\u3002<\/li>\n<li>\u5199\u5165\u7f16\u7801\u4e3aUTF8<\/li>\n<li>\u51fa\u9519\u4e86\u3002\u3002\u3002\u4fe1\u606f\uff1a<span style=\"text-decoration: underline;\"><span style=\"color: #993300;\"><code>TypeError: b'\\xDE\\xD5\\xB4\\xF8' is not JSON serializable<\/code><\/span><\/span><\/li>\n<\/ol>\n<p>\u51fa\u9519\u7684\u539f\u56e0\u662fjson.dump()\u5e76\u4e0d\u652f\u6301bytes\u5bf9\u8c61\u7684\u5e8f\u5217\u5316\u3002\u5982\u679c\u4e00\u5b9a\u8981\u5b58\u50a8bytes\u5bf9\u8c61\uff0c\u5c31\u8981\u81ea\u5df1\u5b9a\u4e49\u5e8f\u5217\u5316\u683c\u5f0f\uff1a<\/p>\n<p><code> def to_json(python_object): \u2460<\/code><br \/>\n<code>\u00a0\u00a0\u00a0 if isinstance(python_object, bytes): \u2461<\/code><br \/>\n<code>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 return {'__class__': 'bytes', <\/code><code>'__value__': list(python_object)} \u2462<\/code><br \/>\n<code>\u00a0\u00a0\u00a0 raise TypeError(repr(python_object) + ' is not JSON serializable') \u2463<\/code><\/p>\n<ol>\n<li>\u5b9a\u4e49\u5e8f\u5217\u5316\u683c\u5f0f\uff0c\u53c2\u6570\u5c31\u662fJSON\u4e0d\u652f\u6301\u7684\u7c7b\u578b\u3002<\/li>\n<li>\u7c7b\u578b\u68c0\u67e5\uff0c\u8fd9\u867d\u7136\u4e0d\u662f\u975e\u5e38\u4e25\u683c\u7684\u8981\u6c42\uff0c\u4f46\u8fd9\u5f88\u91cd\u8981\u3002\u60f3\u4e00\u4e0b\uff0c\u5982\u679c\u4f60\u53ea\u6709\u4e00\u4e2a\u7c7b\u578b\u8981\u5e8f\u5217\u5316\u5230\u6ca1\u4ec0\u4e48\uff0c\u4e00\u4f46\u7c7b\u578b\u591a\u4e86\u7684\u8bdd\u8fd8\u662f\u8981\u533a\u5206\u4e00\u4e0b\u3002<\/li>\n<li>\u5728\u672c\u4f8b\u4e2d\uff0c\u6211\u5df2\u7ecf\u9009\u62e9\u4e86\u8f6c\u6362bytes\u5bf9\u8c61\u5230dictionary\u3002__class__\u5173\u952e\u5b57\u4f1a\u4fdd\u5b58\u539f\u59cb\u7684\u6570\u636e\u7c7b\u578b\uff08\u4ee5\u5b57\u7b26\u4e32\u578b\u5f0f\u6807\u8bb0\u201cbytes\u201d\uff09\uff0c\u5e76\u4e14__value__\u5173\u952e\u5b57\u4fdd\u5b58\u201c\u5b9e\u9645\u7684\u201d\u503c\u3002\u8fd9\u91cc\u6240\u8bf4\u7684\u201c\u5b9e\u9645\u201d\u6307\u7684\u5e76\u4e0d\u662fbytes\uff0c\u800c\u662f\u4e00\u4e2a\u53ef\u4ee5\u88abJSON\u5e8f\u5217\u5316\u7684\u7c7b\u578b\uff0c\u672c\u4f8b\u4e2d\u662flist\uff0c\u56e0\u4e3abytes\u662f\u4e00\u4e32\u6574\u6570\uff0c\u6bcf\u4e2a\u6574\u6570\u7684\u8303\u56f4\u662f0~255\u3002\u6240\u4ee5<span style=\"text-decoration: underline;\"><span style=\"color: #993300; text-decoration: underline;\"><code> b'\\xDE\\xD5\\xB4\\xF8'<\/code><\/span><\/span>\u4f1a\u901a\u8fc7list()\u8f6c\u6362\u6210\u4e00\u4e2a\u5217\u8868 <span style=\"text-decoration: underline; color: #993300;\">[222, 213, 180, 248]<\/span>\u3002\uff08\u5341\u516d\u8fdb\u5236\\xDE\u662f\u5341\u8fdb\u5236\u7684222\uff09<\/li>\n<li>\u8fd9\u4e00\u884c\u5f88\u91cd\u8981\u3002\u5982\u679c\u8fd9\u4e2a\u6570\u636e\u7c7b\u578b\u5373\u4e0d\u662fJSON\u5185\u5efa\u652f\u6301\u7684\uff0c\u4e5f\u4e0d\u662f\u81ea\u5b9a\u4e49\u7684\uff0c\u90a3\u4e48\u5fc5\u987b\u5f15\u53d1\u4e00\u4e2aTypeError\u5f02\u5e38\uff0c\u8fd9\u6837json.dump()\u51fd\u6570\u624d\u4f1a\u77e5\u9053\u4f60\u81ea\u5b9a\u4e49\u5e8f\u5217\u5316\u51fd\u6570\u6ca1\u6709\u6ce8\u518c\u8fd9\u4e2a\u7c7b\u578b\u3002<\/li>\n<\/ol>\n<p>\u8fd9\u5c31\u597d\u4e86\uff0c\u4e0d\u4f60\u9700\u8981\u518d\u505a\u4efb\u4f55\u5176\u5b83\u4e8b\u60c5\u3002\u4f60\u4e0d\u9700\u8981\u505a\u5168\u90e8\u7684\u5e8f\u5217\u5316\u5de5\u4f5c\uff0c\u4f60\u53ea\u9700\u8981\u8f6c\u6362\u6570\u636e\u7c7b\u578b\u5230JSON\u652f\u6301\u7684\u6570\u636e\u7c7b\u578b\u5c31\u53ef\u4ee5\u3002\u5269\u4e0b\u7684\u4e8b\u60c5json.dump()\u51fd\u6570\u4f1a\u53bb\u505a\u3002<\/p>\n<p><code> &gt;&gt;&gt; import customserializer \u2460<\/code><br \/>\n<code>&gt;&gt;&gt; with open('entry.json', 'w', encoding='utf-8') as f: \u2461<\/code><br \/>\n<code>...\u00a0\u00a0\u00a0\u00a0 json.dump(entry, f,default=customserializer.to_json) \u2462<\/code><br \/>\n<code>...<\/code><br \/>\n<code>Traceback (most recent call last):<\/code><br \/>\n<code>File \"&lt;stdin&gt;\", line 9, in &lt;module&gt;<\/code><br \/>\n<code>json.dump(entry, f, default=customserializer.to_json)<\/code><br \/>\n<code>File \"C:\\Python31\\lib\\json\\__init__.py\", line 178, in dump<\/code><br \/>\n<code>for chunk in iterable:<\/code><br \/>\n<code>File \"C:\\Python31\\lib\\json\\encoder.py\", line 408, in _iterencode<\/code><br \/>\n<code>for chunk in _iterencode_dict(o, _current_indent_level):<\/code><br \/>\n<code>File \"C:\\Python31\\lib\\json\\encoder.py\", line 382, in _iterencode_dict<\/code><br \/>\n<code>for chunk in chunks:<\/code><br \/>\n<code>File \"C:\\Python31\\lib\\json\\encoder.py\", line 416, in _iterencode<\/code><br \/>\n<code>o = _default(o)<\/code><br \/>\n<code>File \"\/Users\/pilgrim\/diveintopython3\/examples\/customserializer.py\", line 12, in to_json<\/code><br \/>\n<code>raise TypeError(repr(python_object) + ' is not JSON serializable') \u2463<\/code><br \/>\n<span style=\"text-decoration: underline;\"><span style=\"color: #993300;\"><code>TypeError: time.struct_time(tm_year=2009, tm_mon=3, tm_mday=27, tm_hour=22, tm_min=20, tm_sec=42, tm_wday=4, tm_yday=86, tm_isdst=-1) is not JSON serializable<\/code><\/span><\/span><\/p>\n<ol>\n<li><code>customserializer<\/code>\u6a21\u5757\u5c31\u662f\u521a\u521a\u5b9a\u4e49\u7684<code>to_json()<\/code>\u6240\u5728\u7684\u6a21\u5757\u3002<\/li>\n<li>\u6587\u672c\u5199\u5165\u6a21\u5f0f\uff0cUTF-8\u7f16\u7801<\/li>\n<li>\u8fd9\u91cc\u5f88\u91cd\u8981\uff0c\u628a\u81ea\u5b9a\u4e49\u7684\u8f6c\u6362\u51fd\u6570\u6302\u8f7d\uff08hook\uff09\u5230json.dump()\u4e0a\uff0c\u7528\u81ea\u5df1\u7684\u51fd\u6570\u66ff\u6362\u9ed8\u8ba4\u53c2\u6570\u3002<\/li>\n<li>\u8fd8\u662f\u8f93\u51fa\u4e86\u4e00\u4e2a\u9519\u8bef\uff0c\u56e0\u4e3atime.struct_time\u5bf9\u8c61\u4e0d\u80fd\u5e8f\u5217\u5316\u3002<\/li>\n<\/ol>\n<p>\u518d\u6b21\u8fdb\u884c\u4fee\u6539\uff1a<\/p>\n<p><code> import time<\/code><br \/>\n<code>def to_json(python_object):<\/code><br \/>\n<code>\u00a0\u00a0\u00a0 if isinstance(python_object, time.struct_time): \u2460<\/code><br \/>\n<code>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 return {'__class__': 'time.asctime', <\/code><code>'__value__': time.asctime(python_object)} \u2461<\/code><br \/>\n<code>\u00a0\u00a0\u00a0 if isinstance(python_object, bytes):<\/code><br \/>\n<code>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 return {'__class__': 'bytes', <\/code><code>'__value__': list(python_object)}<\/code><br \/>\n<code>\u00a0\u00a0\u00a0 raise TypeError(repr(python_object) + ' is not JSON serializable')<\/code><\/p>\n<ol>\n<li>\u6dfb\u52a0\u5230\u73b0\u6709\u7684<code>customserializer.to_json()<\/code>\u51fd\u6570\u4e2d\uff0c\u5e76\u68c0\u67e5python_object\u7684\u7c7b\u578b\u662f\u5426\u4e3a<code>time.struct_time<\/code>\u3002<\/li>\n<li>\u5982\u679c\u662f\u7684\u8bdd\uff0c\u6211\u4eec\u5c06\u4f1a\u505a\u4e00\u4e9b\u7c7b\u4f3cbytes\u5bf9\u8c61\u7684\u8f6c\u6362\uff1a\u8f6c\u6362<code>time.struct_time<\/code>\u5bf9\u8c61\u5230\u4e2a\u53ef\u4ee5\u88abjson\u5e8f\u5217\u5316\u7684\u7c7b\u578b\u3002\u672c\u4f8b\u4e2d<code>time.asctime()<\/code>\u51fd\u6570\u8f6c\u6362<code>time.struct_time<\/code>\u7ed3\u6784\u5230<code>string<\/code>\u7c7b\u578b&#8221; Fri Mar 27 22:20:42 2009&#8243;<\/li>\n<\/ol>\n<p>\u8fd9\u65f6\u518d\u6b21\u6267\u884c\uff1a<\/p>\n<p><code> &gt;&gt;&gt; with open('entry.json', 'w', encoding='utf-8') as f:<\/code><br \/>\n<code>...\u00a0\u00a0\u00a0\u00a0 json.dump(entry, f,default=customserializer.to_json)<\/code><\/p>\n<p>\u5c31\u4e0d\u4f1a\u62a5\u4efb\u4f55\u9519\u8bef\u4e86\u3002<\/p>\n<h2>\uff088\uff09\u4ece\u6587\u4ef6\u4e2d\u6062\u590dJSON\u6570\u636e<\/h2>\n<p>\u5c31\u50cfpickle\u6a21\u5757\u4e00\u6837\uff0cjson\u6a21\u5757\u540c\u6837\u4f7f\u7528load()\u51fd\u6570\u5e26\u4e00\u4e2a\u6d41\u5bf9\u8c61\u53c2\u6570\uff0c\u4ece\u4e2d\u8bfb\u53d6JSON\u683c\u5f0f\u5b57\u7b26\u4e32\u3002<\/p>\n<p><code> &gt;&gt;&gt; import json<\/code><br \/>\n<code>&gt;&gt;&gt; with open('entry.json', 'r', encoding='utf-8') as f:<\/code><br \/>\n<code>...\u00a0\u00a0\u00a0\u00a0 entry = json.load(f)\u00a0 \u2460<\/code><br \/>\n<code>...<\/code><br \/>\n<code>&gt;&gt;&gt; entry\u00a0\u00a0\u00a0\u00a0 \u2461<\/code><br \/>\n<code>{'comments_link': None,<\/code><br \/>\n<code>'internal_id': {'__class__': 'bytes', '__value__': [222, 213, 180, 248]},<\/code><br \/>\n<code>'title': 'Dive into history, 2009 edition',<\/code><br \/>\n<code>'tags': ['diveintopython', 'docbook', 'html'],<\/code><br \/>\n<code>'article_link': 'http:\/\/diveintomark.org\/archives\/2009\/03\/27\/dive-into-history-2009-edition',<\/code><br \/>\n<code>'published_date': {'__class__': 'time.asctime', '__value__': 'Fri Mar 27 22:20:42 2009'},<\/code><br \/>\n<code>'published': True}<\/code><\/p>\n<ol>\n<li>\u548cpickle\u6a21\u5757\u7684load\u7528\u6cd5\u4e00\u6837\uff0c\u4f20\u7ed9load()\u4e00\u4e2a\u6d41\u5bf9\u8c61\uff0c\u4e4b\u540e\u5b83\u8fd4\u56de\u4e00\u4e2apython\u5bf9\u8c61\u3002<\/li>\n<li>\u6062\u590d\u6570\u636e\u7ed3\u6784\uff0c\u4e0d\u8fc7\u2018internal_id\u2019\u548c\u2018published_date&#8217;\u88ab\u6062\u590d\u6210\u5b57\u66f2\u7c7b\u578b\uff0c\u56e0\u4e3aload()\u5e76\u4e0d\u77e5\u9053\u8f6c\u6362\u4e4b\u524d\u7684\u81ea\u5b9a\u4e49\u51fd\u6570\u3002<\/li>\n<\/ol>\n<p><span style=\"color: #ff0000;\">\u8981\u60f3\u6062\u590d\u4e4b\u524d\u539f\u6765\u7684\u6570\u636e\u7ed3\u6784\uff0c\u8fd8\u8981\u5b9a\u4e49\u4e00\u4e2a\u4e0eto_json\u505a\u7528\u76f8\u53cd\u7684\u7a0b\u5e8f\u2014\u2014from_json<\/span>\uff1a<\/p>\n<p><code> def from_json(json_object): \u2460<\/code><br \/>\n<code>\u00a0\u00a0\u00a0 if '__class__' in json_object: \u2461<\/code><br \/>\n<code>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if json_object['__class__'] == 'time.asctime':<\/code><br \/>\n<code>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 return time.strptime(json_object['__value__']) \u2462<\/code><br \/>\n<code>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if json_object['__class__'] == 'bytes':<\/code><br \/>\n<code>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 return bytes(json_object['__value__']) \u2463<\/code><br \/>\n<code>\u00a0\u00a0\u00a0 return json_object<\/code><\/p>\n<ol>\n<li>\u8fd9\u4e2a\u8f6c\u6362\u51fd\u6570\u6709\u4e00\u4e2a\u53c2\u6570\u5e76\u8fd4\u56de\u4e00\u4e2a\u503c\u3002\u4f46\u53c2\u6570\u5e76\u4e0d\u662f\u4e00\u4e2a\u5b57\u7b26\u4e32\uff0c\u5b83\u662f\u4e00\u4e2apython\u5bf9\u8c61\u2014\u2014\u4e00\u4e2aJSON\u7f16\u7801\u7684\u5b57\u7b26\u4e32\u4f20\u5230PYTHON\u540e\u7684\u5bf9\u8c61\uff08\u8be6\u89c1\uff1a<span style=\"text-decoration: underline;\"><span style=\"color: #ff0000; text-decoration: underline;\">JSON\u548cPYTHON3\u6570\u636e\u7c7b\u578b\u7684\u5bf9\u5e94\u5173\u7cfb<\/span><\/span>\uff09\u3002<\/li>\n<li>\u7c7b\u578b\u68c0\u67e5\uff0c\u5982\u679c\u53d1\u73b0\u4e86&#8217;__class__&#8217;\uff0c\u5c31\u6309\u6211\u4eec\u5b9a\u4e49\u7684\u65b9\u5f0f\u8fdb\u884c\u6062\u590d<\/li>\n<li>time.asctime()\u548ctime.strptime()\u662f\u4e00\u5bf9\u76f8\u53cd\u7684\u51fd\u6570\uff0casctime()\u5c06time.sruct_time\u7ed3\u6784\u8f6c\u6210\u5b57\u7b26\u4e32\uff0c\u800cstrptime()\u5c06\u5b57\u7b26\u4e32\u8f6c\u6210struct_time\u7ed3\u6784\u3002<\/li>\n<li>\u628a\u4e00\u4e2a\u5217\u8868\u8f6c\u6210bytes\u7c7b\u578b\u3002<\/li>\n<\/ol>\n<p>\u51c6\u5907\u5de5\u4f5c\u5b8c\u6210\uff0c\u8c03\u7528\u65b9\u6cd5\u5982\u4e0b\uff1a<\/p>\n<p><code> &gt;&gt;&gt; import customserializer<\/code><br \/>\n<code>&gt;&gt;&gt; with open('entry.json', 'r', encoding='utf-8') as f:<\/code><br \/>\n<code>... \u00a0 \u00a0 entry = json.load(f, object_hook=customserializer.from_json) \u2460<\/code><br \/>\n<code>...<\/code><br \/>\n<code>&gt;&gt;&gt; entry \u00a0 \u2461<\/code><br \/>\n<code>{'comments_link': None,<\/code><br \/>\n<code>'internal_id': b'\\xDE\\xD5\\xB4\\xF8',<\/code><br \/>\n<code>'title': 'Dive into history, 2009 edition',<\/code><br \/>\n<code>'tags': ['diveintopython', 'docbook', 'html'],<\/code><br \/>\n<code>'article_link': 'http:\/\/diveintomark.org\/archives\/2009\/03\/27\/dive-into-history-2009-edition',<\/code><br \/>\n<code>'published_date': time.struct_time(tm_year=2009, tm_mon=3, tm_mday=27, tm_hour=22, tm_min=20, tm_sec=42, tm_wday=4, tm_yday=86, tm_isdst=-1),<\/code><br \/>\n<code>'published': True}<\/code><\/p>\n<ol>\n<li>\u5c06\u6211\u4eec\u81ea\u5b9a\u4e49\u7684<code>from_json()<\/code>\u51fd\u6570\u6302\u8f7d\uff08hook\uff09\u5230<code>load()<\/code>\u4e0a\uff0c<code>object_hook<\/code>\u53c2\u6570\u662f\u4f20\u9012\u7ed9<code>json.load()<\/code>\u51fd\u6570\u7684\u3002<\/li>\n<li>\u8f93\u51faentry\uff0c\u67e5\u770b\u5b83\u7684\u7ed3\u6784\u3002<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>\uff081\uff09pickle\u6a21\u5757 pickle\u6a21\u5757\u53ef\u4ee5\u5b58\u50a8\u54ea\u4e9b\u7c7b\u578b\uff1f python\u652f\u6301\u7684\u6240\u6709\u672c\u5730\u6570\u636e\u7c7b\u578b\uff1abooleans, intergers, floating po&#8230;<\/p>\n<p class=\"read-more\"><a class=\"btn btn-default\" href=\"https:\/\/www.5x44.cn\/?p=206\"> Read More<span class=\"screen-reader-text\">  Read More<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-206","post","type-post","status-publish","format-standard","hentry","category-dive-into-python3"],"_links":{"self":[{"href":"https:\/\/www.5x44.cn\/index.php?rest_route=\/wp\/v2\/posts\/206","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.5x44.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.5x44.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=206"}],"version-history":[{"count":11,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=\/wp\/v2\/posts\/206\/revisions"}],"predecessor-version":[{"id":230,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=\/wp\/v2\/posts\/206\/revisions\/230"}],"wp:attachment":[{"href":"https:\/\/www.5x44.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=206"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=206"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=206"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}