{"id":496,"date":"2017-02-11T11:19:17","date_gmt":"2017-02-11T03:19:17","guid":{"rendered":"http:\/\/www.rainweb.site\/?p=496"},"modified":"2023-08-07T20:57:29","modified_gmt":"2023-08-07T12:57:29","slug":"python-article46","status":"publish","type":"post","link":"http:\/\/rain1024.com\/index.php\/2017\/02\/11\/python-article46\/","title":{"rendered":"\u8f6c:Python\u7f16\u7801\u7684\u524d\u4e16\u4eca\u751f"},"content":{"rendered":"<p>\u672c\u6587\u5bfc\u822a<br \/>\n- -ASCII<br \/>\n- -EASCII \uff08ISO\/8859-1\uff09<br \/>\n- -GBK<br \/>\n- -Unicode<br \/>\n- -UTF-8<br \/>\n- -Python \u5b57\u7b26\u7f16\u7801<br \/>\n- -str \u4e0e unicode \u7684\u8f6c\u6362<br \/>\n- -str(s) \u4e0e unicode(s)<br \/>\n- -\u4e71\u7801<br \/>\n- -\u5176\u4ed6\u6280\u5de7<\/p>\n<p>\u4e00\u65e6\u8d70\u4e0a\u4e86\u7f16\u7a0b\u4e4b\u8def\uff0c\u5982\u679c\u4f60\u4e0d\u628a\u7f16\u7801\u95ee\u9898\u641e\u6e05\u695a\uff0c\u90a3\u4e48\u5b83\u5c06\u50cf\u5e7d\u7075\u4e00\u822c\u7ea0\u7f20\u4f60\u6574\u4e2a\u804c\u4e1a\u751f\u6daf\uff0c\u5404\u79cd\u7075\u5f02\u4e8b\u4ef6\u4f1a\u63a5\u8e35\u800c\u6765\uff0c\u6325\u4e4b\u4e0d\u53bb\u3002\u53ea\u6709\u5145\u5206\u53d1\u6325\u7a0b\u5e8f\u5458\u6b7b\u78d5\u5230\u5e95\u7684\u7cbe\u795e\u4f60\u624d\u6709\u53ef\u80fd\u5f7b\u5e95\u6446\u8131\u7f16\u7801\u95ee\u9898\u5e26\u6765\u7684\u70e6\u607c\u3002<\/p>\n<p>\u6211\u7b2c\u4e00\u6b21\u9047\u5230\u7f16\u7801\u95ee\u9898\u662f\u5199 JavaWeb \u76f8\u5173\u7684\u9879\u76ee\uff0c\u4e00\u4e32\u5b57\u7b26\u4ece\u6d4f\u89c8\u5668\u6e38\u79bb\u5230\u5e94\u7528\u7a0b\u5e8f\u4ee3\u7801\u4e2d\uff0c\u7ffb\u6c5f\u5012\u6d77\u6c89\u6d78\u5230\u6570\u636e\u5e93\u4e2d\uff0c\u968f\u65f6\u968f\u5730\u90fd\u6709\u53ef\u80fd\u8e29\u5230\u7f16\u7801\u7684\u5730\u96f7\u3002<\/p>\n<p>\u7b2c\u4e8c\u6b21\u9047\u5230\u7f16\u7801\u95ee\u9898\u5c31\u662f\u5b66 Python \u7684\u65f6\u5019\uff0c\u5728\u722c\u53d6\u7f51\u9875\u6570\u636e\u65f6\uff0c\u7f16\u7801\u95ee\u9898\u53c8\u51fa\u73b0\u4e86\uff0c\u5f53\u65f6\u6211\u7684\u5fc3\u60c5\u662f\u5d29\u6e83\u7684\uff0c\u7528\u65f6\u4e0b\u6700ing\u7684\u4e00\u53e5\u8bdd\u5c31\u662f\uff1a\u201c\u6211\u5f53\u65f6\u5c31\u61f5\u903c\u4e86\u201d\u3002<\/p>\n<p>\u4e3a\u4e86\u641e\u6e05\u5b57\u7b26\u7f16\u7801\uff0c\u6211\u4eec\u5f97\u4ece\u8ba1\u7b97\u673a\u7684\u8d77\u6e90\u5f00\u59cb\uff0c\u8ba1\u7b97\u673a\u4e2d\u7684\u6240\u6709\u6570\u636e\uff0c\u4e0d\u8bba\u662f\u6587\u5b57\u3001\u56fe\u7247\u3001\u89c6\u9891\u3001\u8fd8\u662f\u97f3\u9891\u6587\u4ef6\uff0c\u672c\u8d28\u4e0a\u6700\u7ec8\u90fd\u662f\u6309\u7167\u7c7b\u4f3c 01010101 \u7684\u6570\u5b57\u5f62\u5f0f\u5b58\u50a8\u7684\u3002\u6211\u4eec\u662f\u5e78\u8fd0\u7684\uff0c\u6211\u4eec\u4e5f\u662f\u4e0d\u5e78\u7684\uff0c\u5e78\u8fd0\u7684\u662f\u65f6\u4ee3\u8d4b\u4e88\u4e86\u6211\u4eec\u90fd\u6709\u673a\u4f1a\u63a5\u89e6\u8ba1\u7b97\u673a\uff0c\u4e0d\u5e78\u7684\u662f\uff0c\u8ba1\u7b97\u673a\u4e0d\u662f\u6211\u4eec\u56fd\u4eba\u53d1\u660e\u7684\uff0c\u6240\u4ee5\u8ba1\u7b97\u673a\u7684\u6807\u51c6\u5f97\u6309\u7f8e\u5e1d\u56fd\u4eba\u7684\u4e60\u60ef\u6765\u8bbe\u8ba1\uff0c\u90a3\u4e48\u6700\u5f00\u59cb\u8ba1\u7b97\u673a\u662f\u901a\u8fc7\u4ec0\u4e48\u6837\u7684\u65b9\u5f0f\u6765\u8868\u73b0\u5b57\u7b26\u7684\u5462\uff1f\u8fd9\u8981\u4ece\u8ba1\u7b97\u673a\u7f16\u7801\u7684\u53d1\u5c55\u53f2\u8bf4\u8d77\u3002<\/p>\n<p><strong>ASCII<\/strong><\/p>\n<p>\u6bcf\u4e2a\u505a JavaWeb \u5f00\u53d1\u7684\u65b0\u624b\u90fd\u4f1a\u9047\u5230\u4e71\u7801\u95ee\u9898\uff0c\u6bcf\u4e2a\u505a Python \u722c\u866b\u7684\u65b0\u624b\u90fd\u4f1a\u9047\u5230\u7f16\u7801\u95ee\u9898\uff0c\u4e3a\u4ec0\u4e48\u7f16\u7801\u95ee\u9898\u90a3\u4e48\u86cb\u75bc\u5462\uff1f<\/p>\n<p>\u8fd9\u4e2a\u95ee\u9898\u8981\u4ece1992\u5e74 Guido van Rossum \u521b\u9020 Python \u8fd9\u95e8\u8bed\u8a00\u8bf4\u8d77\uff0c\u90a3\u65f6\u7684 Guido \u7edd\u5bf9\u6ca1\u60f3\u5230\u7684\u662f Python \u8fd9\u95e8\u8bed\u8a00\u5728\u4eca\u5929\u4f1a\u5982\u6b64\u53d7\u5927\u5bb6\u6b22\u8fce\uff0c\u4e5f\u4e0d\u4f1a\u60f3\u5230\u8ba1\u7b97\u673a\u53d1\u5c55\u901f\u5ea6\u4f1a\u5982\u6b64\u60ca\u4eba\u3002Guido \u5728\u5f53\u521d\u8bbe\u8ba1\u8fd9\u95e8\u8bed\u8a00\u65f6\u662f\u4e0d\u9700\u8981\u5173\u5fc3\u7f16\u7801\u7684\uff0c\u56e0\u4e3a\u5728\u82f1\u8bed\u4e16\u754c\u91cc\uff0c\u5b57\u7b26\u7684\u4e2a\u6570\u975e\u5e38\u6709\u9650\uff0c26\u4e2a\u5b57\u6bcd\uff08\u5927\u5c0f\u5199\uff09\u300110\u4e2a\u6570\u5b57\u3001\u6807\u70b9\u7b26\u53f7\u3001\u63a7\u5236\u7b26\uff0c\u4e5f\u5c31\u662f\u952e\u76d8\u4e0a\u6240\u6709\u7684\u952e\u6240\u5bf9\u5e94\u7684\u5b57\u7b26\u52a0\u8d77\u6765\u4e5f\u4e0d\u8fc7\u662f\u4e00\u767e\u591a\u4e2a\u5b57\u7b26\u800c\u5df2\u3002\u8fd9\u5728\u8ba1\u7b97\u673a\u4e2d\u7528\u4e00\u4e2a\u5b57\u8282\u7684\u5b58\u50a8\u7a7a\u95f4\u6765\u8868\u793a\u4e00\u4e2a\u5b57\u7b26\u662f\u7ef0\u7ef0\u6709\u4f59\u7684\uff0c\u56e0\u4e3a\u4e00\u4e2a\u5b57\u8282\u76f8\u5f53\u4e8e8\u4e2a\u6bd4\u7279\u4f4d\uff0c8\u4e2a\u6bd4\u7279\u4f4d\u53ef\u4ee5\u8868\u793a256\u4e2a\u7b26\u53f7\u3002\u4e8e\u662f\u806a\u660e\u7684\u7f8e\u56fd\u4eba\u5c31\u5236\u5b9a\u4e86\u4e00\u5957\u5b57\u7b26\u7f16\u7801\u7684\u6807\u51c6\u53eb ASCII(American Standard Code for Information Interchange)\uff0c\u6bcf\u4e2a\u5b57\u7b26\u90fd\u5bf9\u5e94\u552f\u4e00\u7684\u4e00\u4e2a\u6570\u5b57\uff0c\u6bd4\u5982\u5b57\u7b26<code>A<\/code>\u5bf9\u5e94\u7684\u4e8c\u8fdb\u5236\u6570\u503c\u662f<code>01000001<\/code>\uff0c\u5bf9\u5e94\u7684\u5341\u8fdb\u5236\u5c31\u662f 65\u3002\u6700\u5f00\u59cb ASCII \u53ea\u5b9a\u4e49\u4e86 128 \u4e2a\u5b57\u7b26\u7f16\u7801\uff0c\u5305\u62ec 96 \u4e2a\u6587\u5b57\u548c 32 \u4e2a\u63a7\u5236\u7b26\u53f7\uff0c\u4e00\u5171 128 \u4e2a\u5b57\u7b26\uff0c\u53ea\u9700\u8981\u4e00\u4e2a\u5b57\u8282\u7684 7 \u4f4d\u5c31\u80fd\u8868\u793a\u6240\u6709\u7684\u5b57\u7b26\uff0c\u56e0\u6b64 ASCII \u53ea\u4f7f\u7528\u4e86\u4e00\u4e2a\u5b57\u8282\u7684\u540e7\u4f4d\uff0c\u6700\u9ad8\u4f4d\u90fd\u4e3a 0\u3002\u6bcf\u4e2a\u5b57\u7b26\u4e0eASCII\u7801\u7684\u5bf9\u5e94\u5173\u7cfb\u53ef\u67e5\u770b\u7f51\u7ad9ascii-code[2]\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/blog-1252406596.costj.myqcloud.com\/blog\/python32.jpg\" width=\"1178\" height=\"906\" class=\"alignnone size-medium\" \/><\/p>\n<p><strong>EASCII \uff08ISO\/8859-1\uff09<\/strong><\/p>\n<p>\u7136\u800c\u8ba1\u7b97\u673a\u6162\u6162\u5730\u666e\u53ca\u5230\u5176\u4ed6\u897f\u6b27\u5730\u533a\u65f6\uff0c\u4ed6\u4eec\u53d1\u73b0\u8fd8\u6709\u5f88\u591a\u897f\u6b27\u6240\u7279\u6709\u7684\u5b57\u7b26\u662f ASCII \u7f16\u7801\u8868\u4e2d\u6ca1\u6709\u7684\uff0c\u4e8e\u662f\u540e\u6765\u51fa\u73b0\u4e86\u53ef\u6269\u5c55\u7684 ASCII \u53eb EASCII \uff0c\u987e\u540d\u601d\u4e49\uff0c\u5b83\u662f\u5728 ASCII \u7684\u57fa\u7840\u4e0a\u6269\u5c55\u800c\u6765\uff0c\u628a\u539f\u6765\u7684 7 \u4f4d\u6269\u5145\u5230 8 \u4f4d\uff0c\u5b83\u5b8c\u5168\u517c\u5bb9 ASCII\uff0c\u6269\u5c55\u51fa\u6765\u7684\u7b26\u53f7\u5305\u62ec\u8868\u683c\u7b26\u53f7\u3001\u8ba1\u7b97\u7b26\u53f7\u3001\u5e0c\u814a\u5b57\u6bcd\u548c\u7279\u6b8a\u7684\u62c9\u4e01\u7b26\u53f7\u3002\u7136\u800c EASCII \u65f6\u4ee3\u662f\u4e00\u4e2a\u6df7\u4e71\u7684\u65f6\u4ee3\uff0c\u5927\u5bb6\u6ca1\u6709\u7edf\u4e00\u6807\u51c6\uff0c\u4ed6\u4eec\u5404\u81ea\u628a\u6700\u9ad8\u4f4d\u6309\u7167\u81ea\u5df1\u7684\u6807\u51c6\u5b9e\u73b0\u4e86\u81ea\u5df1\u7684\u4e00\u5957\u5b57\u7b26\u7f16\u7801\u6807\u51c6\uff0c\u6bd4\u8f83\u8457\u540d\u7684\u5c31\u6709\u00a0<strong>CP437<\/strong>\uff0c CP437 \u662f Windows \u7cfb\u7edf\u4e2d\u4f7f\u7528\u7684\u5b57\u7b26\u7f16\u7801<\/p>\n<p><em>cp437<\/em><\/p>\n<p>\u53e6\u5916\u4e00\u79cd\u88ab\u5e7f\u6cdb\u4f7f\u7528\u7684 EASCII \u8fd8\u6709\u00a0<strong>ISO\/8859-1(Latin-1)<\/strong>\uff0c\u5b83\u662f\u56fd\u9645\u6807\u51c6\u5316\u7ec4\u7ec7\uff08ISO\uff09\u53ca\u56fd\u9645\u7535\u5de5\u59d4\u5458\u4f1a\uff08IEC\uff09\u8054\u5408\u5236\u5b9a\u7684\u4e00\u7cfb\u52178\u4f4d\u5143\u5b57\u7b26\u96c6\u7684\u6807\u51c6\uff0cISO\/8859-1 \u53ea\u7ee7\u627f\u4e86 CP437 \u5b57\u7b26\u7f16\u7801\u7684 128-159 \u4e4b\u95f4\u7684\u5b57\u7b26\uff0c\u6240\u4ee5\u5b83\u662f\u4ece 160 \u5f00\u59cb\u5b9a\u4e49\u7684\uff0c\u4e0d\u5e78\u7684\u662f\u8fd9\u4e9b\u4f17\u591a\u7684 ASCII \u6269\u5145\u5b57\u96c6\u4e4b\u95f4\u4e92\u4e0d\u517c\u5bb9\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/blog-1252406596.costj.myqcloud.com\/blog\/python33.jpg\" width=\"771\" height=\"430\" class=\"alignnone size-medium\" \/><\/p>\n<p><em>iso8859-1<\/em><\/p>\n<p><strong>GBK<\/strong><\/p>\n<p>\u968f\u7740\u65f6\u4ee3\u7684\u8fdb\u6b65\uff0c\u8ba1\u7b97\u673a\u5f00\u59cb\u666e\u53ca\u5230\u5343\u5bb6\u4e07\u6237\uff0c\u6bd4\u5c14\u76d6\u8328\u8ba9\u6bcf\u4e2a\u4eba\u684c\u9762\u90fd\u6709\u4e00\u53f0\u7535\u8111\u7684\u68a6\u60f3\u5f97\u4ee5\u5b9e\u73b0\u3002\u4f46\u662f\u8ba1\u7b97\u673a\u8fdb\u5165\u4e2d\u56fd\u4e0d\u5f97\u4e0d\u9762\u4e34\u7684\u4e00\u4e2a\u95ee\u9898\u5c31\u662f\u5b57\u7b26\u7f16\u7801\uff0c\u867d\u7136\u54b1\u4eec\u56fd\u5bb6\u7684\u6c49\u5b57\u662f\u4eba\u7c7b\u4f7f\u7528\u9891\u7387\u6700\u591a\u7684\u6587\u5b57\uff0c\u6c49\u5b57\u535a\u5927\u7cbe\u6df1\uff0c\u5e38\u89c1\u7684\u6c49\u5b57\u5c31\u6709\u6210\u5343\u4e0a\u4e07\uff0c\u8fd9\u5df2\u7ecf\u5927\u5927\u8d85\u51fa\u4e86 ASCII \u7f16\u7801\u6240\u80fd\u8868\u793a\u7684\u5b57\u7b26\u8303\u56f4\u4e86\uff0c\u5373\u4f7f\u662f EASCII \u4e5f\u663e\u5f97\u676f\u6c34\u8f66\u85aa\uff0c\u4e8e\u662f\u806a\u660e\u7684\u4e2d\u56fd\u4eba\u81ea\u5df1\u5f04\u4e86\u4e00\u5957\u7f16\u7801\u53eb\u00a0<strong>GB2312<\/strong>\uff0c\u53c8\u79f0GB0\uff0c1981\u7531\u4e2d\u56fd\u56fd\u5bb6\u6807\u51c6\u603b\u5c40\u53d1\u5e03\u3002GB2312 \u7f16\u7801\u5171\u6536\u5f55\u4e866763\u4e2a\u6c49\u5b57\uff0c\u540c\u65f6\u5b83\u8fd8\u517c\u5bb9 ASCII\u3002GB2312 \u7684\u51fa\u73b0\uff0c\u57fa\u672c\u6ee1\u8db3\u4e86\u6c49\u5b57\u7684\u8ba1\u7b97\u673a\u5904\u7406\u9700\u8981\uff0c\u5b83\u6240\u6536\u5f55\u7684\u6c49\u5b57\u5df2\u7ecf\u8986\u76d6\u4e2d\u56fd\u5927\u9646 99.75% \u7684\u4f7f\u7528\u9891\u7387\u3002\u4e0d\u8fc7 GB2312 \u8fd8\u662f\u4e0d\u80fd 100% \u6ee1\u8db3\u4e2d\u56fd\u6c49\u5b57\u7684\u9700\u6c42\uff0c\u5bf9\u4e00\u4e9b\u7f55\u89c1\u7684\u5b57\u548c\u7e41\u4f53\u5b57 GB2312 \u6ca1\u6cd5\u5904\u7406\uff0c\u540e\u6765\u5c31\u5728 GB2312 \u7684\u57fa\u7840\u4e0a\u521b\u5efa\u4e86\u4e00\u79cd\u53eb GBK \u7684\u7f16\u7801\u3002GBK \u4e0d\u4ec5\u6536\u5f55\u4e86 27484 \u4e2a\u6c49\u5b57\uff0c\u540c\u65f6\u8fd8\u6536\u5f55\u4e86\u85cf\u6587\u3001\u8499\u6587\u3001\u7ef4\u543e\u5c14\u6587\u7b49\u4e3b\u8981\u7684\u5c11\u6570\u6c11\u65cf\u6587\u5b57\u3002\u540c\u6837 GBK \u4e5f\u662f\u517c\u5bb9 ASCII \u7f16\u7801\u7684\uff0c\u5bf9\u4e8e\u82f1\u6587\u5b57\u7b26\u7528 1 \u4e2a\u5b57\u8282\u6765\u8868\u793a\uff0c\u6c49\u5b57\u7528\u4e24\u4e2a\u5b57\u8282\u6765\u6807\u8bc6\u3002<\/p>\n<p><strong>Unicode<\/strong><\/p>\n<p>\u5bf9\u4e8e\u5982\u4f55\u5904\u7406\u4e2d\u56fd\u4eba\u81ea\u5df1\u7684\u6587\u5b57\u6211\u4eec\u53ef\u4ee5\u53e6\u7acb\u5c71\u5934\uff0c\u6309\u7167\u6211\u4eec\u81ea\u5df1\u7684\u9700\u6c42\u5236\u5b9a\u4e00\u5957\u7f16\u7801\u89c4\u8303\uff0c\u4f46\u662f\u8ba1\u7b97\u673a\u4e0d\u6b62\u662f\u7f8e\u56fd\u4eba\u548c\u4e2d\u56fd\u4eba\u7528\u554a\uff0c\u8fd8\u6709\u6b27\u6d32\u3001\u4e9a\u6d32\u5176\u4ed6\u56fd\u5bb6\u7684\u6587\u5b57\u8bf8\u5982\u65e5\u6587\u3001\u97e9\u6587\u5168\u4e16\u754c\u5404\u5730\u7684\u6587\u5b57\u52a0\u8d77\u6765\u4f30\u8ba1\u4e5f\u6709\u597d\u51e0\u5341\u4e07\uff0c\u8fd9\u5df2\u7ecf\u5927\u5927\u8d85\u51fa\u4e86 ASCII \u7801\u751a\u81f3 GBK \u6240\u80fd\u8868\u793a\u7684\u8303\u56f4\u4e86\uff0c\u51b5\u4e14\u4eba\u5bb6\u4e3a\u4ec0\u4e48\u7528\u91c7\u7528\u4f60 GBK \u6807\u51c6\u5462\uff1f\u5982\u6b64\u5e9e\u5927\u7684\u5b57\u7b26\u5e93\u7a76\u7adf\u7528\u4ec0\u4e48\u65b9\u5f0f\u6765\u8868\u793a\u597d\u5462\uff1f\u4e8e\u662f\u7edf\u4e00\u8054\u76df\u56fd\u9645\u7ec4\u7ec7\u63d0\u51fa\u4e86 Unicode \u7f16\u7801\uff0cUnicode \u7684\u5b66\u540d\u662f\u201cUniversal Multiple-Octet Coded Character Set\u201d\uff0c\u7b80\u79f0\u4e3aUCS\u3002<\/p>\n<p>Unicode \u6709\u4e24\u79cd\u683c\u5f0f\uff1aUCS-2 \u548c UCS-4\u3002UCS-2 \u5c31\u662f\u7528\u4e24\u4e2a\u5b57\u8282\u7f16\u7801\uff0c\u4e00\u5171 16 \u4e2a\u6bd4\u7279\u4f4d\uff0c\u8fd9\u6837\u7406\u8bba\u4e0a\u6700\u591a\u53ef\u4ee5\u8868\u793a 65536\u4e2a\u5b57\u7b26\uff0c\u4e0d\u8fc7\u8981\u8868\u793a\u5168\u4e16\u754c\u6240\u6709\u7684\u5b57\u7b26\u663e\u7136 65536 \u4e2a\u6570\u5b57\u8fd8\u8fdc\u8fdc\u4e0d\u591f\uff0c\u56e0\u4e3a\u5149\u6c49\u5b57\u5c31\u6709\u8fd1 10 \u4e07\u4e2a\uff0c\u56e0\u6b64 Unicode 4.0 \u89c4\u8303\u5b9a\u4e49\u4e86\u4e00\u7ec4\u9644\u52a0\u7684\u5b57\u7b26\u7f16\u7801\uff0cUCS-4 \u5c31\u662f\u7528 4 \u4e2a\u5b57\u8282\uff08\u5b9e\u9645\u4e0a\u53ea\u7528\u4e86 31 \u4f4d\uff0c\u6700\u9ad8\u4f4d\u5fc5\u987b\u4e3a 0\uff09\u3002<\/p>\n<p>Unicode \u7406\u8bba\u4e0a\u5b8c\u5168\u53ef\u4ee5\u6db5\u76d6\u4e00\u5207\u8bed\u8a00\u6240\u7528\u7684\u7b26\u53f7\u3002\u4e16\u754c\u4e0a\u4efb\u4f55\u4e00\u4e2a\u5b57\u7b26\u90fd\u53ef\u4ee5\u7528\u4e00\u4e2a Unicode \u7f16\u7801\u6765\u8868\u793a\uff0c\u4e00\u65e6\u5b57\u7b26\u7684 Unicode \u7f16\u7801\u786e\u5b9a\u4e0b\u6765\u540e\uff0c\u5c31\u4e0d\u4f1a\u518d\u6539\u53d8\u4e86\u3002\u4f46\u662f Unicode \u6709\u4e00\u5b9a\u7684\u5c40\u9650\u6027\uff0c\u4e00\u4e2a Unicode \u5b57\u7b26\u5728\u7f51\u7edc\u4e0a\u4f20\u8f93\u6216\u8005\u6700\u7ec8\u5b58\u50a8\u8d77\u6765\u7684\u65f6\u5019\uff0c\u5e76\u4e0d\u89c1\u5f97\u6bcf\u4e2a\u5b57\u7b26\u90fd\u9700\u8981\u4e24\u4e2a\u5b57\u8282\uff0c\u6bd4\u5982\u4e00\u5b57\u7b26\u201c<code>A<\/code>\u201c\uff0c\u7528\u4e00\u4e2a\u5b57\u8282\u5c31\u53ef\u4ee5\u8868\u793a\u7684\u5b57\u7b26\uff0c\u504f\u504f\u8fd8\u8981\u7528\u4e24\u4e2a\u5b57\u8282\uff0c\u663e\u7136\u592a\u6d6a\u8d39\u7a7a\u95f4\u4e86\u3002\u7b2c\u4e8c\u95ee\u9898\u662f\uff0c\u4e00\u4e2a Unicode \u5b57\u7b26\u4fdd\u5b58\u5230\u8ba1\u7b97\u673a\u91cc\u9762\u65f6\u5c31\u662f\u4e00\u4e32 01 \u6570\u5b57\uff0c\u90a3\u4e48\u8ba1\u7b97\u673a\u600e\u4e48\u77e5\u9053\u4e00\u4e2a 2 \u5b57\u8282\u7684 Unicode \u5b57\u7b26\u662f\u8868\u793a\u4e00\u4e2a 2 \u5b57\u8282\u7684\u5b57\u7b26\u5462\uff0c\u8fd8\u662f\u8868\u793a\u4e24\u4e2a 1 \u5b57\u8282\u7684\u5b57\u7b26\u5462\uff0c\u5982\u679c\u4f60\u4e0d\u4e8b\u5148\u544a\u8bc9\u8ba1\u7b97\u673a\uff0c\u90a3\u4e48\u8ba1\u7b97\u673a\u4e5f\u4f1a\u61f5\u903c\u4e86\u3002Unicode \u53ea\u662f\u89c4\u5b9a\u5982\u4f55\u7f16\u7801\uff0c\u5e76\u6ca1\u6709\u89c4\u5b9a\u5982\u4f55\u4f20\u8f93\u3001\u4fdd\u5b58\u8fd9\u4e2a\u7f16\u7801\u3002\u4f8b\u5982\u201c<code>\u6c49<\/code>\u201d\u5b57\u7684 Unicode \u7f16\u7801\u662f<code>6C49<\/code>\uff0c\u6211\u53ef\u4ee5\u7528 4 \u4e2a ASCII \u6570\u5b57\u6765\u4f20\u8f93\u3001\u4fdd\u5b58\u8fd9\u4e2a\u7f16\u7801\uff1b\u4e5f\u53ef\u4ee5\u7528 UTF-8 \u7f16\u7801\u7684 3 \u4e2a\u8fde\u7eed\u7684\u5b57\u8282<code>E6 B1 89<\/code>\u6765\u8868\u793a\u5b83\u3002\u5173\u952e\u5728\u4e8e\u901a\u4fe1\u53cc\u65b9\u90fd\u8981\u8ba4\u53ef\u3002\u56e0\u6b64 Unicode \u7f16\u7801\u6709\u4e0d\u540c\u7684\u5b9e\u73b0\u65b9\u5f0f\uff0c\u6bd4\u5982\uff1aUTF-8\u3001UTF-16 \u7b49\u7b49\u3002\u8fd9\u91cc\u7684 Unicode \u5c31\u50cf\u82f1\u8bed\u4e00\u6837\uff0c\u505a\u4e3a\u56fd\u4e0e\u56fd\u4e4b\u95f4\u4ea4\u6d41\u4e16\u754c\u901a\u7528\u7684\u6807\u51c6\uff0c\u6bcf\u4e2a\u56fd\u5bb6\u6709\u81ea\u5df1\u7684\u8bed\u8a00\uff0c\u4ed6\u4eec\u628a\u6807\u51c6\u7684\u82f1\u6587\u6587\u6863\u7ffb\u8bd1\u6210\u81ea\u5df1\u56fd\u5bb6\u7684\u6587\u5b57\uff0c\u8fd9\u662f\u5b9e\u73b0\u65b9\u5f0f\uff0c\u5c31\u50cf UTF-8\u3002<\/p>\n<p><strong>UTF-8<\/strong><\/p>\n<p>UTF-8\uff08Unicode Transformation Format\uff09\u4f5c\u4e3a Unicode \u7684\u4e00\u79cd\u5b9e\u73b0\u65b9\u5f0f\uff0c\u5e7f\u6cdb\u5e94\u7528\u4e8e\u4e92\u8054\u7f51\uff0c\u5b83\u662f\u4e00\u79cd\u53d8\u957f\u7684\u5b57\u7b26\u7f16\u7801\uff0c\u53ef\u4ee5\u6839\u636e\u5177\u4f53\u60c5\u51b5\u7528 1-4 \u4e2a\u5b57\u8282\u6765\u8868\u793a\u4e00\u4e2a\u5b57\u7b26\u3002\u6bd4\u5982\u82f1\u6587\u5b57\u7b26\u8fd9\u4e9b\u539f\u672c\u5c31\u53ef\u4ee5\u7528 ASCII \u7801\u8868\u793a\u7684\u5b57\u7b26\u7528 UTF-8 \u8868\u793a\u65f6\u5c31\u53ea\u9700\u8981\u4e00\u4e2a\u5b57\u8282\u7684\u7a7a\u95f4\uff0c\u548c ASCII \u662f\u4e00\u6837\u7684\u3002\u5bf9\u4e8e\u591a\u5b57\u8282\uff08n \u4e2a\u5b57\u8282\uff09\u7684\u5b57\u7b26\uff0c\u7b2c\u4e00\u4e2a\u5b57\u8282\u7684\u524d n \u4e3a\u90fd\u8bbe\u4e3a 1\uff0c\u7b2c n+1 \u4f4d\u8bbe\u4e3a 0\uff0c\u540e\u9762\u5b57\u8282\u7684\u524d\u4e24\u4f4d\u90fd\u8bbe\u4e3a 10\u3002\u5269\u4e0b\u7684\u4e8c\u8fdb\u5236\u4f4d\u5168\u90e8\u7528\u8be5\u5b57\u7b26\u7684 UNICODE \u7801\u586b\u5145\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/blog-1252406596.costj.myqcloud.com\/blog\/python34.jpg\" width=\"771\" height=\"430\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u4ee5\u6c49\u5b57\u201c<code>\u597d<\/code>\u201d\u4e3a\u4f8b\uff0c\u201c<code>\u597d<\/code>\u201d\u5bf9\u5e94\u7684 Unicode \u662f<code>597D<\/code>\uff0c\u5bf9\u5e94\u7684\u533a\u95f4\u662f<code>0000 0800<\/code>--<code>0000 FFFF<\/code>\uff0c\u56e0\u6b64\u5b83\u7528 UTF-8 \u8868\u793a\u65f6\u9700\u8981\u7528 3 \u4e2a\u5b57\u8282\u6765\u5b58\u50a8\uff0c<code>597D<\/code>\u7528\u4e8c\u8fdb\u5236\u8868\u793a\u662f\uff1a<code>0101100101111101<\/code>\uff0c\u586b\u5145\u5230<code>1110xxxx 10xxxxxx 10xxxxxx<\/code>\u5f97\u5230<code>11100101 10100101 10111101<\/code>\uff0c\u8f6c\u6362\u6210 16 \u8fdb\u5236\uff1a<code>E5A5BD<\/code>\uff0c\u56e0\u6b64\u201c<code>\u597d<\/code>\u201d\u7684 Unicode \u201c<code>597D<\/code>\u201d\u5bf9\u5e94\u7684 UTF-8 \u7f16\u7801\u662f\u201c<code>E5A5BD<\/code>\u201d\u3002<\/p>\n<pre><code>\u4e2d\u6587 \u597dunicode 0101 100101 111101\u7f16\u7801\u89c4\u5219 1110xxxx 10xxxxxx 10xxxxxx--------------------------utf-8 11100101 10100101 10111101--------------------------16\u8fdb\u5236utf-8 e 5 a 5 b d\n<\/code><\/pre>\n<p><strong>Python \u5b57\u7b26\u7f16\u7801<\/strong><\/p>\n<p>\u73b0\u5728\u603b\u7b97\u628a\u7406\u8bba\u8bf4\u5b8c\u4e86\u3002\u518d\u6765\u8bf4\u8bf4 Python \u4e2d\u7684\u7f16\u7801\u95ee\u9898\u3002Python \u7684\u8bde\u751f\u65f6\u95f4\u6bd4 Unicode \u8981\u65e9\u5f88\u591a\uff0cPython \u7684\u9ed8\u8ba4\u7f16\u7801\u662fASCII\u3002<\/p>\n<p>\u6240\u4ee5\u5728 Python \u6e90\u4ee3\u7801\u6587\u4ef6\u4e2d\u5982\u679c\u4e0d\u663e\u5f0f\u5730\u6307\u5b9a\u7f16\u7801\u7684\u8bdd\uff0c\u5c06\u51fa\u73b0\u8bed\u6cd5\u9519\u8bef<\/p>\n<pre><code>#test.pyprint \"\u4f60\u597d\"\n<\/code><\/pre>\n<p>\u4e0a\u9762\u662f test.py \u811a\u672c\uff0c\u8fd0\u884c\u00a0<code>python test.py<\/code>\u5c31\u4f1a\u5305\u5982\u4e0b\u9519\u8bef\uff1a<\/p>\n<pre><code>File \u201ctest.py\u201d, line 1 yntaxError: Non-ASCII character \u2018\\xe4\u2032 in file test.py on line 1, but no encoding declared; see http:\/\/www.python.org\/ ps\/pep-0263.html for details\n<\/code><\/pre>\n<p>\u4e3a\u4e86\u5728\u6e90\u4ee3\u7801\u4e2d\u652f\u6301\u975e ASCII \u5b57\u7b26\uff0c\u5fc5\u987b\u5728\u6e90\u6587\u4ef6\u7684\u7b2c\u4e00\u884c\u6216\u8005\u7b2c\u4e8c\u884c\u663e\u793a\u5730\u6307\u5b9a\u7f16\u7801\u683c\u5f0f\uff1a<\/p>\n<pre><code># coding=utf-8\n<\/code><\/pre>\n<p>\u6216\u8005\u662f\uff1a<\/p>\n<pre><code>#!\/usr\/bin\/python# -*- coding: utf-8 -*-\n<\/code><\/pre>\n<p>\u5728 Python \u4e2d\u548c\u5b57\u7b26\u4e32\u76f8\u5173\u7684\u6570\u636e\u7c7b\u578b\uff0c\u5206\u522b\u662f\u00a0<strong>str<\/strong>\u3001<strong>unicode\u00a0<\/strong>\u4e24\u79cd\uff0c\u4ed6\u4eec\u90fd\u662f<strong>basestring<\/strong>\u7684\u5b50\u7c7b\uff0c\u53ef\u89c1 str \u4e0e unicode \u662f\u4e24\u79cd\u4e0d\u540c\u7c7b\u578b\u7684\u5b57\u7b26\u4e32\u5bf9\u8c61\u3002<\/p>\n<pre><code>basestring\/ \\ \/ \\str unicode\n<\/code><\/pre>\n<p>\u5bf9\u4e8e\u540c\u4e00\u4e2a\u6c49\u5b57\u201c<code>\u597d<\/code>\u201d\uff0c\u7528 str \u8868\u793a\u65f6\uff0c\u5b83\u5bf9\u5e94\u7684\u5c31\u662f UTF-8 \u7f16\u7801<code>'\\xe5\\xa5\\xbd'<\/code>\uff0c\u800c\u7528 Unicode \u8868\u793a\u65f6\uff0c\u5b83\u5bf9\u5e94\u7684\u7b26\u53f7\u5c31\u662f<code>u'\\u597d'<\/code>\uff0c\u4e0e<code>u\"\u597d\"<\/code>\u662f\u7b49\u540c\u7684\u3002\u9700\u8981\u8865\u5145\u4e00\u70b9\u7684\u662f\uff0cstr \u7c7b\u578b\u7684\u5b57\u7b26\u5176\u5177\u4f53\u7684\u7f16\u7801\u683c\u5f0f\u662f UTF-8 \u8fd8\u662f GBK\uff0c\u8fd8\u662f\u5176\u5b83\u683c\u5f0f\uff0c\u6839\u636e\u64cd\u4f5c\u7cfb\u7edf\u76f8\u5173\u3002\u6bd4\u5982\u5728 Windows \u7cfb\u7edf\u4e2d\uff0ccmd \u547d\u4ee4\u884c\u4e2d\u663e\u793a\u7684\uff1a<\/p>\n<pre><code># windows\u7ec8\u7aef&gt;&gt;&gt; a = '\u597d'&gt;&gt;&gt; type(a)&lt;type 'str'&gt;&gt;&gt;&gt; a'\\xba\\xc3'\n<\/code><\/pre>\n<p>\u800c\u5728 Linux \u7cfb\u7edf\u7684\u547d\u4ee4\u884c\u4e2d\u663e\u793a\u7684\u662f\uff1a<\/p>\n<pre><code># linux\u7ec8\u7aef&gt;&gt;&gt; a='\u597d'&gt;&gt;&gt; type(a)&lt;type 'str'&gt;&gt;&gt;&gt; a'\\xe5\\xa5\\xbd'&gt;&gt;&gt; b=u'\u597d'&gt;&gt;&gt; type(b)&lt;type 'unicode'&gt;&gt;&gt;&gt; bu'\\u597d'\n<\/code><\/pre>\n<p>\u4e0d\u8bba\u662f Python3x\u3001Java \u8fd8\u662f\u5176\u4ed6\u7f16\u7a0b\u8bed\u8a00\uff0cUnicode \u7f16\u7801\u90fd\u6210\u4e3a\u4e86\u8bed\u8a00\u7684\u9ed8\u8ba4\u7f16\u7801\u683c\u5f0f\uff0c\u800c\u6570\u636e\u6700\u540e\u4fdd\u5b58\u5230\u4ecb\u8d28\u4e2d\u7684\u65f6\u5019\uff0c\u4e0d\u540c\u7684\u4ecb\u8d28\u53ef\u6709\u7528\u4e0d\u540c\u7684\u65b9\u5f0f\uff0c\u6709\u4e9b\u4eba\u559c\u6b22\u7528 UTF-8\uff0c\u6709\u4e9b\u4eba\u559c\u6b22\u7528 GBK\uff0c\u8fd9\u90fd\u65e0\u6240\u8c13\uff0c\u53ea\u8981\u5e73\u53f0\u7edf\u4e00\u7684\u7f16\u7801\u89c4\u8303\uff0c\u5177\u4f53\u600e\u4e48\u5b9e\u73b0\u5e76\u4e0d\u5173\u5fc3\u3002<\/p>\n<p><em>encode<\/em><\/p>\n<p><strong>str \u4e0e unicode \u7684\u8f6c\u6362<\/strong><\/p>\n<p>\u90a3\u4e48\u5728 Python \u4e2d str \u548c unicode \u4e4b\u95f4\u662f\u5982\u4f55\u8f6c\u6362\u7684\u5462\uff1f\u8fd9\u4e24\u79cd\u7c7b\u578b\u7684\u5b57\u7b26\u4e32\u7c7b\u578b\u4e4b\u95f4\u7684\u8f6c\u6362\u5c31\u662f\u9760\u8fd9\u4e24\u4e2a\u65b9\u6cd5\uff1a<code>decode<\/code>\u548c<code>encode<\/code>\u3002<\/p>\n<p><em>py-encode<\/em><\/p>\n<pre><code>#\u4ecestr\u7c7b\u578b\u8f6c\u6362\u5230unicodes.decode(encoding) =====&gt; &lt;type 'str'&gt; to &lt;type 'unicode'&gt;#\u4eceunicode\u8f6c\u6362\u5230stru.encode(encoding) =====&gt; &lt;type 'unicode'&gt; to &lt;type 'str'&gt;&gt;&gt;&gt; c = b.encode('utf-8')&gt;&gt;&gt; type(c)&lt;type 'str'&gt;&gt;&gt;&gt; c'\\xe5\\xa5\\xbd'&gt;&gt;&gt; d = c.decode('utf-8')&gt;&gt;&gt; type(d)&lt;type 'unicode'&gt;&gt;&gt;&gt; du'\\u597d'\n<\/code><\/pre>\n<p>\u8fd9\u4e2a<code>'\\xe5\\xa5\\xbd'<\/code>\u5c31\u662f Unicode<code>u'\u597d'<\/code>\u901a\u8fc7\u51fd\u6570<code>encode<\/code>\u7f16\u7801\u5f97\u5230\u7684 UTF-8 \u7f16\u7801\u7684 str \u7c7b\u578b\u7684\u5b57\u7b26\u4e32\u3002\u53cd\u4e4b\u4ea6\u7136\uff0cstr \u7c7b\u578b\u7684 c \u901a\u8fc7\u51fd\u6570<code>decode<\/code>\u89e3\u7801\u6210 Unicode \u5b57\u7b26\u4e32 d\u3002<\/p>\n<p><strong>str(s) \u4e0e unicode(s)<\/strong><\/p>\n<p><code>str(s)<\/code>\u548c<code>unicode(s)<\/code>\u662f\u4e24\u4e2a\u5de5\u5382\u65b9\u6cd5\uff0c\u5206\u522b\u8fd4\u56de str \u5b57\u7b26\u4e32\u5bf9\u8c61\u548c Unicode \u5b57\u7b26\u4e32\u5bf9\u8c61\uff0c<code>str(s)<\/code>\u662f<code>s.encode(\u2018ascii\u2019)<\/code>\u7684\u7b80\u5199\u3002\u5b9e\u9a8c\uff1a<\/p>\n<pre><code>&gt;&gt;&gt; s3 = u\"\u4f60\u597d\"&gt;&gt;&gt; s3u'\\u4f60\\u597d'&gt;&gt;&gt; str(s3)Traceback (most recent call last):File \"&lt;stdin&gt;\", line 1, in &lt;module&gt;UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)\n<\/code><\/pre>\n<p>\u4e0a\u9762\u00a0<code>s3<\/code>\u662f Unicode \u7c7b\u578b\u7684\u5b57\u7b26\u4e32\uff0c<code>str(s3)<\/code>\u76f8\u5f53\u4e8e\u662f\u6267\u884c<code>s3.encode(\u2018ascii\u2019)<\/code>\uff0c\u56e0\u4e3a\u201c<code>\u4f60\u597d<\/code>\u201d\u4e24\u4e2a\u6c49\u5b57\u4e0d\u80fd\u7528 ASCII \u7801\u6765\u8868\u793a\uff0c\u6240\u4ee5\u5c31\u62a5\u9519\u4e86\uff0c\u6307\u5b9a\u6b63\u786e\u7684\u7f16\u7801\uff1a<code>s3.encode('gbk')<\/code>\u6216\u8005<code>s3.encode('utf-8')<\/code>\u5c31\u4e0d\u4f1a\u51fa\u73b0\u8fd9\u4e2a\u95ee\u9898\u4e86\u3002\u7c7b\u4f3c\u7684 Unicode \u6709\u540c\u6837\u7684\u9519\u8bef\uff1a<\/p>\n<pre><code>&gt;&gt;&gt; s4 = \"\u4f60\u597d\"&gt;&gt;&gt; unicode(s4)Traceback (most recent call last):File \"&lt;stdin&gt;\", line 1, in &lt;module&gt;UnicodeDecodeError: 'ascii' codec can't decode byte 0xc4 in position 0: ordinal not in range(128)&gt;&gt;&gt;\n<\/code><\/pre>\n<p><code>unicode(s4)<\/code>\u7b49\u6548\u4e8e<code>s4.decode('ascii')<\/code>\uff0c\u56e0\u6b64\u8981\u6b63\u786e\u7684\u8f6c\u6362\u5c31\u8981\u6b63\u786e\u6307\u5b9a\u5176\u7f16\u7801<code>s4.decode('gbk')<\/code>\u6216\u8005<code>s4.decode('utf-8')<\/code>\u3002<\/p>\n<p><strong>\u4e71\u7801<\/strong><\/p>\n<p>\u6240\u6709\u51fa\u73b0\u4e71\u7801\u7684\u539f\u56e0\u90fd\u53ef\u4ee5\u5f52\u7ed3\u4e3a\u5b57\u7b26\u7ecf\u8fc7\u4e0d\u540c\u7f16\u7801\u89e3\u7801\u5728\u7f16\u7801\u7684\u8fc7\u7a0b\u4e2d\u4f7f\u7528\u7684\u7f16\u7801\u683c\u5f0f\u4e0d\u4e00\u81f4\uff0c\u6bd4\u5982\uff1a<\/p>\n<pre><code># encoding: utf-8&gt;&gt;&gt; a='\u597d'&gt;&gt;&gt; a'\\xe5\\xa5\\xbd'&gt;&gt;&gt; b=a.decode(\"utf-8\")&gt;&gt;&gt; bu'\\u597d'&gt;&gt;&gt; c=b.encode(\"gbk\")&gt;&gt;&gt; c'\\xba\\xc3'&gt;&gt;&gt; print c\n<\/code><\/pre>\n<p>UTF-8 \u7f16\u7801\u7684\u5b57\u7b26\u2018<code>\u597d<\/code>\u2019\u5360\u7528 3 \u4e2a\u5b57\u8282\uff0c\u89e3\u7801\u6210 Unicode \u540e\uff0c\u5982\u679c\u518d\u7528 GBK \u6765\u89e3\u7801\u540e\uff0c\u53ea\u6709 2 \u4e2a\u5b57\u8282\u7684\u957f\u5ea6\u4e86\uff0c\u6700\u540e\u51fa\u73b0\u4e86\u4e71\u7801\u7684\u95ee\u9898\uff0c\u56e0\u6b64\u9632\u6b62\u4e71\u7801\u7684\u6700\u597d\u65b9\u5f0f\u5c31\u662f\u59cb\u7ec8\u575a\u6301\u4f7f\u7528\u540c\u4e00\u79cd\u7f16\u7801\u683c\u5f0f\u5bf9\u5b57\u7b26\u8fdb\u884c\u7f16\u7801\u548c\u89e3\u7801\u64cd\u4f5c\u3002<\/p>\n<p><em>decode-encode<\/em><\/p>\n<p><strong>\u5176\u4ed6\u6280\u5de7<\/strong><\/p>\n<p>\u5bf9\u4e8e\u5982 Unicode \u5f62\u5f0f\u7684\u5b57\u7b26\u4e32\uff08str \u7c7b\u578b)\uff1a<\/p>\n<pre><code>s = 'id\\u003d215903184\\u0026index\\u003d0\\u0026st\\u003d52\\u0026sid'\n<\/code><\/pre>\n<p>\u8f6c\u6362\u6210\u771f\u6b63\u7684 Unicode \u9700\u8981\u4f7f\u7528\uff1a<\/p>\n<pre><code>s.decode('unicode-escape')\n<\/code><\/pre>\n<p>\u6d4b\u8bd5\uff1a<\/p>\n<pre><code>&gt;&gt;&gt; s = 'id\\u003d215903184\\u0026index\\u003d0\\u0026st\\u003d52\\u0026sid\\u003d95000\\u0026i'&gt;&gt;&gt; print(type(s))&lt;type 'str'&gt;&gt;&gt;&gt; s = s.decode('unicode-escape')&gt;&gt;&gt; su'id=215903184&amp;index=0&amp;st=52&amp;sid=95000&amp;i'&gt;&gt;&gt; print(type(s))&lt;type 'unicode'&gt;&gt;&gt;&gt;\n<\/code><\/pre>\n<p>\u4ee5\u4e0a\u4ee3\u7801\u548c\u6982\u5ff5\u90fd\u662f\u57fa\u4e8e Python2.x\u3002<\/p>\n<p>\u4ee5\u4e0a\u4ee3\u7801\u548c\u6982\u5ff5\u90fd\u662f\u57fa\u4e8e Python2.x\u3002<\/p>\n<p>\u53c2\u8003\uff1a<\/p>\n<blockquote><p>\u8f6c\u8f7d\u81ea\uff1a http:\/\/foofish.net\/blog\/111\/python-character-encode<br \/>\u4f5c\u8005\uff1a _zhijun<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587\u5bfc\u822a &#8211; -ASCII &#8211; -EASCII \uff08ISO\/8859-1\uff09 &#8211; -GBK &#8211; -Unicode \u2026 <span class=\"read-more\"><a href=\"http:\/\/rain1024.com\/index.php\/2017\/02\/11\/python-article46\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":349,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[58,85],"class_list":["post-496","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-python","tag-code"],"_links":{"self":[{"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/posts\/496","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/comments?post=496"}],"version-history":[{"count":1,"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/posts\/496\/revisions"}],"predecessor-version":[{"id":1494,"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/posts\/496\/revisions\/1494"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/media\/349"}],"wp:attachment":[{"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/media?parent=496"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/categories?post=496"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/tags?post=496"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}