{"id":204116,"date":"2025-05-29T09:26:41","date_gmt":"2025-05-29T01:26:41","guid":{"rendered":"https:\/\/server.hk\/cnblog\/204116\/"},"modified":"2025-05-29T09:26:41","modified_gmt":"2025-05-29T01:26:41","slug":"python%e4%bb%a3%e7%a0%81%e6%a8%a1%e6%9d%bf%e8%ae%be%e7%bd%ae%e8%af%a6%e8%a7%a3%ef%bc%9a%e7%bc%96%e7%a0%81%e6%a0%bc%e5%bc%8f%e3%80%81%e5%88%86%e9%9a%94%e7%ac%a6%e5%8f%b7%e5%92%8c%e4%b8%89%e5%bc%95","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/204116\/","title":{"rendered":"Python\u4ee3\u7801\u6a21\u677f\u8bbe\u7f6e\u8be6\u89e3\uff1a\u7f16\u7801\u683c\u5f0f\u3001\u5206\u9694\u7b26\u53f7\u548c\u4e09\u5f15\u53f7\u6ce8\u91ca\u7684\u7591\u95ee\u89e3\u7b54"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>Python\u4ee3\u7801\u6a21\u677f\u8bbe\u7f6e\u8be6\u89e3\uff1a\u7f16\u7801\u683c\u5f0f\u3001\u5206\u9694\u7b26\u53f7\u548c\u4e09\u5f15\u53f7\u6ce8\u91ca\u7684\u7591\u95ee\u89e3\u7b54<\/h1>\n<p>\u201c\u7eb5\u6709\u75be\u98ce\u6765\uff0c\u4eba\u751f\u4e0d\u8a00\u5f03\u201d\uff0c\u8fd9\u53e5\u8bdd\u9001\u7ed9\u6b63\u5728\u5b66\u4e60\u7684\u670b\u53cb\u4eec\uff0c\u4e5f\u5e0c\u671b\u5728\u9605\u8bfb\u672c\u6587<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300aPython\u4ee3\u7801\u6a21\u677f\u8bbe\u7f6e\u8be6\u89e3\uff1a\u7f16\u7801\u683c\u5f0f\u3001\u5206\u9694\u7b26\u53f7\u548c\u4e09\u5f15\u53f7\u6ce8\u91ca\u7684\u7591\u95ee\u89e3\u7b54\u300b<\/span>\u540e\uff0c\u80fd\u591f\u771f\u7684\u5e2e\u52a9\u5230\u5927\u5bb6\u3002\u6211\u4e5f\u4f1a\u5728\u540e\u7eed\u7684\u6587\u7ae0\u4e2d\uff0c\u9646\u7eed\u66f4\u65b0<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u6587\u7ae0<\/span>\u76f8\u5173\u7684\u6280\u672f\u6587\u7ae0\uff0c\u6709\u597d\u7684\u5efa\u8bae\u6b22\u8fce\u5927\u5bb6\u5728\u8bc4\u8bba\u7559\u8a00\uff0c\u975e\u5e38\u611f\u8c22\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241028\/1730117212671f7e5ce39f8.jpg\" class=\"aligncenter\"><\/p>\n<p><strong>Python \u4ee3\u7801\u6a21\u677f\u8bbe\u7f6e\u8be6\u89e3<\/strong><\/p>\n<p>\u6b63\u5982\u95ee\u9898\u6240\u63d0\uff0cPython \u4ee3\u7801\u6a21\u677f\u8bbe\u7f6e\u66fe\u7ecf\u5b58\u5728\u4e00\u4e9b\u4e89\u8bae\uff0c\u4f46\u5982\u4eca\u5df2\u9010\u6e10\u660e\u6717\u3002\u672c\u6587\u5c06\u6df1\u5165\u63a2\u8ba8\u8fd9\u4e9b\u8bbe\u7f6e\uff0c\u56de\u7b54\u76f8\u5173\u7591\u95ee\u3002<\/p>\n<p><strong>\u7f16\u7801\u683c\u5f0f\u58f0\u660e<\/strong><\/p>\n<ul>\n<li><strong>\u95ee\u9898 1\uff1a\u4ee5\u4e0a\u58f0\u660e\u7684\u4ee3\u7801\u7f16\u7801\u683c\u5f0f\u90fd\u884c\u5417\uff1f<\/strong><\/li>\n<\/ul>\n<p>\u7b54\u6848\uff1a\u662f\u7684\u3002Python \u652f\u6301\u591a\u79cd\u7f16\u7801\u683c\u5f0f\uff0c\u5305\u62ec UTF-8\u3001UTF-16 \u548c UTF-32\u3002\u4e0a\u8ff0\u58f0\u660e\u5747\u53ef\u6709\u6548\u8bbe\u7f6e\u4ee3\u7801\u6587\u4ef6\u7684\u7f16\u7801\u683c\u5f0f\u3002<\/p>\n<ul>\n<li><strong>\u95ee\u9898 2\uff1a\u7cfb\u7edf\u771f\u7684\u4f1a\u67e5\u770b\u8fd9\u6761\u6ce8\u91ca\u7684\u7f16\u7801\u683c\u5f0f\u7533\u660e\u5417\uff1f<\/strong><\/li>\n<\/ul>\n<p>\u7b54\u6848\uff1a\u662f\u7684\u3002Python \u89e3\u91ca\u5668\u4f1a\u5728\u89e3\u91ca\u4ee3\u7801\u4e4b\u524d\u68c0\u67e5\u6587\u4ef6\u5f00\u5934\u5904\u7684\u7f16\u7801\u683c\u5f0f\u58f0\u660e\u3002\u5982\u679c\u58f0\u660e\u4e0d\u517c\u5bb9\u6587\u4ef6\u4e2d\u7684\u5b9e\u9645\u7f16\u7801\u683c\u5f0f\uff0c\u89e3\u91ca\u5668\u5c06\u62a5\u544a\u9519\u8bef\u3002<\/p>\n<p><strong>\u5206\u9694\u7b26\u53f7<\/strong><\/p>\n<ul>\n<li><strong>\u95ee\u9898 3\uff1a\u7b49\u53f7 (=) \u548c\u5192\u53f7 (:) \u8fd9\u4e24\u4e2a\u7b26\u53f7\u90fd\u53ef\u4ee5\u5417\uff1f<\/strong><\/li>\n<\/ul>\n<p>\u7b54\u6848\uff1a\u662f\u7684\u3002\u5206\u9694\u7b26\u53f7\u53ef\u4ee5\u662f\u7b49\u53f7\u6216\u5192\u53f7\uff0c\u5747\u53ef\u6709\u6548\u6307\u5b9a\u7f16\u7801\u683c\u5f0f\u3002<\/p>\n<ul>\n<li><strong>\u95ee\u9898 4\uff1acoding \u548c encoding \u4e5f\u90fd\u53ef\u4ee5\u5417\uff1f<\/strong><\/li>\n<\/ul>\n<p>\u7b54\u6848\uff1a\u662f\u7684\u3002coding \u548c encoding \u5173\u952e\u8bcd\u53ef\u4ee5\u4e92\u6362\u4f7f\u7528\u3002<\/p>\n<p><strong>\u4e09\u5f15\u53f7\u6ce8\u91ca<\/strong><\/p>\n<ul>\n<li><strong>\u95ee\u9898 5\uff1a\u7528\u4e09\u5f15\u53f7\u6ce8\u91ca\u53ef\u4ee5\u5417\uff1f<\/strong><\/li>\n<\/ul>\n<p>\u7b54\u6848\uff1a\u4e0d\u3002\u6587\u672c\u5757\u4e09\u5f15\u53f7\u4e0d\u80fd\u7528\u4e8e\u8bbe\u7f6e\u4ee3\u7801\u6a21\u677f\u3002\u4e0e\u5176\u4ed6\u6ce8\u91ca\u4e0d\u540c\uff0c\u6587\u672c\u5757\u6ce8\u91ca\u4e0d\u4f1a\u88ab\u89e3\u91ca\u5668\u89e3\u6790\u3002<\/p>\n<p><strong>\u53c2\u8003\u6587\u6863<\/strong><\/p>\n<p>\u5982\u9700\u4e86\u89e3\u66f4\u591a\u8be6\u7ec6\u4fe1\u606f\uff0c\u8bf7\u53c2\u9605 Python \u5b98\u65b9\u6587\u6863\uff1a<\/p>\n<ul>\n<li>[PEP 263 \u2013 Defining Python Source Code Encodings](https:\/\/peps.python.org\/pep-0263\/)<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u300aPython\u4ee3\u7801\u6a21\u677f\u8bbe\u7f6e\u8be6\u89e3\uff1a\u7f16\u7801\u683c\u5f0f\u3001\u5206\u9694\u7b26\u53f7\u548c\u4e09\u5f15\u53f7\u6ce8\u91ca\u7684\u7591\u95ee\u89e3\u7b54\u300b\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u5173\u4e8e\u7684\u8d44\u6599\u8bf7\u5173\u6ce8\u516c\u4f17\u53f7\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Python\u4ee3\u7801\u6a21\u677f\u8bbe\u7f6e\u8be6\u89e3\uff1a\u7f16&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4925],"tags":[],"class_list":["post-204116","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/204116","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=204116"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/204116\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=204116"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=204116"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=204116"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}