{"id":1104624,"date":"2025-01-08T16:22:36","date_gmt":"2025-01-08T08:22:36","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1104624.html"},"modified":"2025-01-08T16:22:38","modified_gmt":"2025-01-08T08:22:38","slug":"python3%e4%b8%ad%e5%ad%97%e7%ac%a6%e6%98%af%e5%a6%82%e4%bd%95%e5%ae%9e%e7%8e%b0%e7%9a%84","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1104624.html","title":{"rendered":"python3\u4e2d\u5b57\u7b26\u662f\u5982\u4f55\u5b9e\u73b0\u7684"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25065914\/a9cfafb2-a028-4cb9-b248-52ea36aed99a.webp\" alt=\"python3\u4e2d\u5b57\u7b26\u662f\u5982\u4f55\u5b9e\u73b0\u7684\" \/><\/p>\n<p><p> \u5728Python3\u4e2d\uff0c\u5b57\u7b26\u662f\u901a\u8fc7Unicode\u7f16\u7801\u5b9e\u73b0\u7684\u3001\u6bcf\u4e2a\u5b57\u7b26\u5360\u7528\u7684\u5b57\u8282\u6570\u662f\u52a8\u6001\u7684\u3001\u53ef\u4ee5\u901a\u8fc7\u5185\u7f6e\u51fd\u6570\u548c\u6a21\u5757\u8fdb\u884c\u64cd\u4f5c\u3002Unicode\u7f16\u7801\u652f\u6301\u5168\u7403\u5927\u90e8\u5206\u7684\u4e66\u5199\u7cfb\u7edf\uff0c\u4f7f\u5f97Python3\u80fd\u591f\u5904\u7406\u5404\u79cd\u8bed\u8a00\u7684\u5b57\u7b26\u3002<strong>\u6bcf\u4e2a\u5b57\u7b26\u5360\u7528\u7684\u5b57\u8282\u6570\u662f\u52a8\u6001\u7684<\/strong>\uff0c\u5177\u4f53\u53d6\u51b3\u4e8e\u5b57\u7b26\u672c\u8eab\uff0c\u8fd9\u5c31\u610f\u5473\u7740\u4e0d\u540c\u7684\u5b57\u7b26\u53ef\u80fd\u5360\u7528\u4e0d\u540c\u6570\u91cf\u7684\u5b57\u8282\uff0c\u4ece\u800c\u786e\u4fdd\u4e86\u5185\u5b58\u4f7f\u7528\u7684\u9ad8\u6548\u6027\u3002Python3\u4f7f\u7528\u5185\u7f6e\u51fd\u6570\u548c\u6a21\u5757\uff08\u5982ord()\u3001chr()\u3001unicodedata\u7b49\uff09\u6765\u5904\u7406\u548c\u64cd\u4f5c\u5b57\u7b26\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001Unicode\u7f16\u7801\u5728Python3\u4e2d\u7684\u5b9e\u73b0<\/h3>\n<\/p>\n<p><p>Python3\u9ed8\u8ba4\u4f7f\u7528Unicode\u7f16\u7801\u6765\u8868\u793a\u5b57\u7b26\u4e32\u3002\u8fd9\u4e0ePython2\u4e0d\u540c\uff0c\u540e\u8005\u9ed8\u8ba4\u4f7f\u7528ASCII\u7f16\u7801\u3002Unicode\u662f\u4e00\u79cd\u5b57\u7b26\u7f16\u7801\u6807\u51c6\uff0c\u80fd\u591f\u8868\u793a\u51e0\u4e4e\u6240\u6709\u7684\u4e66\u5199\u7cfb\u7edf\u4e2d\u7684\u5b57\u7b26\u3002Python3\u4e2d\u7684\u6bcf\u4e2a\u5b57\u7b26\u90fd\u662f\u4e00\u4e2aUnicode\u5b57\u7b26\uff0c\u8fd9\u4f7f\u5f97Python3\u80fd\u591f\u5904\u7406\u5404\u79cd\u8bed\u8a00\u7684\u6587\u672c\u3002<\/p>\n<\/p>\n<p><p>Unicode\u5b57\u7b26\u5728Python3\u4e2d\u7531<code>str<\/code>\u7c7b\u578b\u8868\u793a\u3002<code>str<\/code>\u7c7b\u578b\u5b9e\u9645\u4e0a\u662f\u4e00\u4e2aUnicode\u5b57\u7b26\u4e32\u5e8f\u5217\u3002\u8fd9\u610f\u5473\u7740\u6bcf\u4e2a\u5b57\u7b26\u4e32\u90fd\u662f\u4e00\u4e2aUnicode\u5b57\u7b26\u5e8f\u5217\uff0c\u800c\u4e0d\u662f\u5b57\u8282\u5e8f\u5217\u3002Python3\u4e2d\u7684\u5b57\u7b26\u4e32\u53ef\u4ee5\u5305\u542b\u4efb\u4f55Unicode\u5b57\u7b26\uff0c\u5305\u62ec\u4e2d\u6587\u3001\u65e5\u6587\u3001\u97e9\u6587\u3001\u963f\u62c9\u4f2f\u6587\u7b49\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u52a8\u6001\u5b57\u8282\u6570<\/h3>\n<\/p>\n<p><p>\u5728Python3\u4e2d\uff0c\u6bcf\u4e2a\u5b57\u7b26\u5360\u7528\u7684\u5b57\u8282\u6570\u662f\u52a8\u6001\u7684\u3002\u8fd9\u662f\u56e0\u4e3a\u4e0d\u540c\u7684Unicode\u5b57\u7b26\u5728\u5185\u5b58\u4e2d\u5360\u7528\u7684\u5b57\u8282\u6570\u4e0d\u540c\u3002Python3\u4f7f\u7528\u4e00\u79cd\u79f0\u4e3a&quot;\u7075\u6d3b\u5b57\u7b26\u4e32\u8868\u793a&quot;\uff08Flexible String Representation\uff09\u7684\u673a\u5236\u6765\u4f18\u5316\u5185\u5b58\u4f7f\u7528\u3002\u8fd9\u79cd\u673a\u5236\u6839\u636e\u5b57\u7b26\u4e32\u4e2d\u7684\u6700\u5927Unicode\u7801\u4f4d\u6765\u9009\u62e9\u6700\u5408\u9002\u7684\u5b58\u50a8\u65b9\u5f0f\u3002<\/p>\n<\/p>\n<p><p>\u5177\u4f53\u6765\u8bf4\uff0cPython3\u4e2d\u7684\u5b57\u7b26\u4e32\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u4e09\u79cd\u5b58\u50a8\u65b9\u5f0f\u4e4b\u4e00\uff1a<\/p>\n<\/p>\n<ol>\n<li><strong>ASCII<\/strong>\uff1a\u6bcf\u4e2a\u5b57\u7b26\u4f7f\u75281\u4e2a\u5b57\u8282\uff0c\u9002\u7528\u4e8e\u6240\u6709\u5b57\u7b26\u7684Unicode\u7801\u4f4d\u57280\u5230127\u4e4b\u95f4\u7684\u5b57\u7b26\u4e32\u3002<\/li>\n<li><strong>UCS-2<\/strong>\uff1a\u6bcf\u4e2a\u5b57\u7b26\u4f7f\u75282\u4e2a\u5b57\u8282\uff0c\u9002\u7528\u4e8e\u6240\u6709\u5b57\u7b26\u7684Unicode\u7801\u4f4d\u57280\u523065535\u4e4b\u95f4\u7684\u5b57\u7b26\u4e32\u3002<\/li>\n<li><strong>UCS-4<\/strong>\uff1a\u6bcf\u4e2a\u5b57\u7b26\u4f7f\u75284\u4e2a\u5b57\u8282\uff0c\u9002\u7528\u4e8e\u6240\u6709\u5b57\u7b26\u7684Unicode\u7801\u4f4d\u57280\u52301114111\u4e4b\u95f4\u7684\u5b57\u7b26\u4e32\u3002<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u8fd9\u79cd\u673a\u5236\uff0cPython3\u80fd\u591f\u5728\u4fdd\u8bc1\u5b57\u7b26\u4e32\u5904\u7406\u6027\u80fd\u7684\u540c\u65f6\uff0c\u5c3d\u53ef\u80fd\u5730\u8282\u7701\u5185\u5b58\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u5185\u7f6e\u51fd\u6570\u548c\u6a21\u5757<\/h3>\n<\/p>\n<p><p>Python3\u63d0\u4f9b\u4e86\u8bb8\u591a\u5185\u7f6e\u51fd\u6570\u548c\u6a21\u5757\u6765\u5904\u7406\u548c\u64cd\u4f5c\u5b57\u7b26\u3002\u8fd9\u4e9b\u5de5\u5177\u4f7f\u5f97\u5b57\u7b26\u64cd\u4f5c\u53d8\u5f97\u975e\u5e38\u65b9\u4fbf\u548c\u9ad8\u6548\u3002<\/p>\n<\/p>\n<p><h4>1. ord() \u548c chr()<\/h4>\n<\/p>\n<p><p><code>ord()<\/code>\u51fd\u6570\u7528\u4e8e\u83b7\u53d6\u5b57\u7b26\u7684Unicode\u7801\u4f4d\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">print(ord(&#39;A&#39;))  # \u8f93\u51fa\uff1a65<\/p>\n<p>print(ord(&#39;\u4e2d&#39;))  # \u8f93\u51fa\uff1a20013<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><code>chr()<\/code>\u51fd\u6570\u7528\u4e8e\u6839\u636eUnicode\u7801\u4f4d\u83b7\u53d6\u5bf9\u5e94\u7684\u5b57\u7b26\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">print(chr(65))  # \u8f93\u51fa\uff1aA<\/p>\n<p>print(chr(20013))  # \u8f93\u51fa\uff1a\u4e2d<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. unicodedata \u6a21\u5757<\/h4>\n<\/p>\n<p><p><code>unicodedata<\/code>\u6a21\u5757\u63d0\u4f9b\u4e86\u8bb8\u591a\u7528\u4e8e\u64cd\u4f5cUnicode\u5b57\u7b26\u7684\u5de5\u5177\u3002\u5b83\u53ef\u4ee5\u83b7\u53d6\u5b57\u7b26\u7684\u540d\u79f0\u3001\u5206\u7c7b\u3001\u89c4\u8303\u5316\u5f62\u5f0f\u7b49\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import unicodedata<\/p>\n<p>print(unicodedata.name(&#39;A&#39;))  # \u8f93\u51fa\uff1aLATIN CAPITAL LETTER A<\/p>\n<p>print(unicodedata.category(&#39;A&#39;))  # \u8f93\u51fa\uff1aLu\uff08\u8868\u793a\u5927\u5199\u5b57\u6bcd\uff09<\/p>\n<p>print(unicodedata.normalize(&#39;NFC&#39;, &#39;e\\u0301&#39;))  # \u8f93\u51fa\uff1a\u00e9<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u56db\u3001\u5b57\u7b26\u4e32\u64cd\u4f5c<\/h3>\n<\/p>\n<p><p>Python3\u4e2d\u7684\u5b57\u7b26\u4e32\u662f\u4e0d\u53ef\u53d8\u7684\uff0c\u8fd9\u610f\u5473\u7740\u4e00\u65e6\u521b\u5efa\uff0c\u5b57\u7b26\u4e32\u7684\u5185\u5bb9\u5c31\u4e0d\u80fd\u6539\u53d8\u3002\u7136\u800c\uff0cPython3\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u5b57\u7b26\u4e32\u64cd\u4f5c\u65b9\u6cd5\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u5bf9\u5b57\u7b26\u4e32\u8fdb\u884c\u5904\u7406\u3002<\/p>\n<\/p>\n<p><h4>1. \u5b57\u7b26\u4e32\u5207\u7247<\/h4>\n<\/p>\n<p><p>\u5b57\u7b26\u4e32\u5207\u7247\u662f\u4e00\u79cd\u4ece\u5b57\u7b26\u4e32\u4e2d\u63d0\u53d6\u5b50\u5b57\u7b26\u4e32\u7684\u65b9\u5f0f\u3002Python3\u4e2d\u7684\u5b57\u7b26\u4e32\u5207\u7247\u8bed\u6cd5\u975e\u5e38\u7b80\u6d01\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">s = &quot;Hello, world!&quot;<\/p>\n<p>print(s[0:5])  # \u8f93\u51fa\uff1aHello<\/p>\n<p>print(s[7:])  # \u8f93\u51fa\uff1aworld!<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. \u5b57\u7b26\u4e32\u8fde\u63a5<\/h4>\n<\/p>\n<p><p>Python3\u63d0\u4f9b\u4e86\u591a\u79cd\u65b9\u5f0f\u6765\u8fde\u63a5\u5b57\u7b26\u4e32\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u4f7f\u7528\u52a0\u53f7\uff08<code>+<\/code>\uff09\u64cd\u4f5c\u7b26\u6216<code>join()<\/code>\u65b9\u6cd5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">s1 = &quot;Hello&quot;<\/p>\n<p>s2 = &quot;world&quot;<\/p>\n<p>print(s1 + &quot;, &quot; + s2 + &quot;!&quot;)  # \u8f93\u51fa\uff1aHello, world!<\/p>\n<p>print(&quot;, &quot;.join([s1, s2]))  # \u8f93\u51fa\uff1aHello, world<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3. \u5b57\u7b26\u4e32\u683c\u5f0f\u5316<\/h4>\n<\/p>\n<p><p>Python3\u63d0\u4f9b\u4e86\u591a\u79cd\u5b57\u7b26\u4e32\u683c\u5f0f\u5316\u65b9\u6cd5\uff0c\u5305\u62ec<code>%<\/code>\u64cd\u4f5c\u7b26\u3001<code>str.format()<\/code>\u65b9\u6cd5\u548cf\u5b57\u7b26\u4e32\uff08f-strings\uff09\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">name = &quot;Alice&quot;<\/p>\n<p>age = 30<\/p>\n<p>print(&quot;My name is %s and I am %d years old.&quot; % (name, age))  # \u8f93\u51fa\uff1aMy name is Alice and I am 30 years old.<\/p>\n<p>print(&quot;My name is {} and I am {} years old.&quot;.format(name, age))  # \u8f93\u51fa\uff1aMy name is Alice and I am 30 years old.<\/p>\n<p>print(f&quot;My name is {name} and I am {age} years old.&quot;)  # \u8f93\u51fa\uff1aMy name is Alice and I am 30 years old.<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e94\u3001\u7f16\u7801\u548c\u89e3\u7801<\/h3>\n<\/p>\n<p><p>\u5728\u5904\u7406\u6587\u672c\u65f6\uff0c\u6709\u65f6\u9700\u8981\u5728\u4e0d\u540c\u7684\u5b57\u7b26\u7f16\u7801\u4e4b\u95f4\u8fdb\u884c\u8f6c\u6362\u3002Python3\u63d0\u4f9b\u4e86<code>encode()<\/code>\u548c<code>decode()<\/code>\u65b9\u6cd5\u6765\u5b9e\u73b0\u8fd9\u4e00\u70b9\u3002<\/p>\n<\/p>\n<p><h4>1. \u7f16\u7801<\/h4>\n<\/p>\n<p><p><code>encode()<\/code>\u65b9\u6cd5\u7528\u4e8e\u5c06\u5b57\u7b26\u4e32\u7f16\u7801\u4e3a\u5b57\u8282\u5e8f\u5217\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">s = &quot;Hello, \u4e16\u754c!&quot;<\/p>\n<p>b = s.encode(&#39;utf-8&#39;)<\/p>\n<p>print(b)  # \u8f93\u51fa\uff1ab&#39;Hello, \\xe4\\xb8\\x96\\xe7\\x95\\x8c!&#39;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. \u89e3\u7801<\/h4>\n<\/p>\n<p><p><code>decode()<\/code>\u65b9\u6cd5\u7528\u4e8e\u5c06\u5b57\u8282\u5e8f\u5217\u89e3\u7801\u4e3a\u5b57\u7b26\u4e32\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">b = b&#39;Hello, \\xe4\\xb8\\x96\\xe7\\x95\\x8c!&#39;<\/p>\n<p>s = b.decode(&#39;utf-8&#39;)<\/p>\n<p>print(s)  # \u8f93\u51fa\uff1aHello, \u4e16\u754c!<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u516d\u3001\u5904\u7406\u591a\u8bed\u8a00\u6587\u672c<\/h3>\n<\/p>\n<p><p>Python3\u4e2d\u7684Unicode\u652f\u6301\u4f7f\u5f97\u5904\u7406\u591a\u8bed\u8a00\u6587\u672c\u53d8\u5f97\u975e\u5e38\u5bb9\u6613\u3002\u65e0\u8bba\u662f\u4e2d\u6587\u3001\u65e5\u6587\u3001\u97e9\u6587\u8fd8\u662f\u5176\u4ed6\u8bed\u8a00\uff0cPython3\u90fd\u80fd\u591f\u5904\u7406\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">s = &quot;\u4f60\u597d, \u4e16\u754c!&quot;<\/p>\n<p>print(s)  # \u8f93\u51fa\uff1a\u4f60\u597d, \u4e16\u754c!<\/p>\n<p>print(ord(&#39;\u4f60&#39;))  # \u8f93\u51fa\uff1a20320<\/p>\n<p>print(chr(20320))  # \u8f93\u51fa\uff1a\u4f60<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e03\u3001\u5b57\u7b26\u5206\u7c7b\u548c\u5224\u65ad<\/h3>\n<\/p>\n<p><p>\u5728\u5904\u7406\u5b57\u7b26\u4e32\u65f6\uff0c\u901a\u5e38\u9700\u8981\u5bf9\u5b57\u7b26\u8fdb\u884c\u5206\u7c7b\u548c\u5224\u65ad\u3002Python3\u63d0\u4f9b\u4e86\u4e00\u4e9b\u5185\u7f6e\u65b9\u6cd5\u6765\u5b9e\u73b0\u8fd9\u4e00\u70b9\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">s = &quot;Hello123&quot;<\/p>\n<p>print(s.isalpha())  # \u8f93\u51fa\uff1aFalse\uff08\u56e0\u4e3a\u5305\u542b\u6570\u5b57\uff09<\/p>\n<p>print(s.isdigit())  # \u8f93\u51fa\uff1aFalse\uff08\u56e0\u4e3a\u5305\u542b\u5b57\u6bcd\uff09<\/p>\n<p>print(s.isalnum())  # \u8f93\u51fa\uff1aTrue\uff08\u56e0\u4e3a\u53ea\u5305\u542b\u5b57\u6bcd\u548c\u6570\u5b57\uff09<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u603b\u4e4b\uff0cPython3\u4e2d\u7684\u5b57\u7b26\u5904\u7406\u662f\u901a\u8fc7Unicode\u7f16\u7801\u5b9e\u73b0\u7684\uff0c\u6bcf\u4e2a\u5b57\u7b26\u5360\u7528\u7684\u5b57\u8282\u6570\u662f\u52a8\u6001\u7684\uff0c\u53ef\u4ee5\u901a\u8fc7\u5185\u7f6e\u51fd\u6570\u548c\u6a21\u5757\u8fdb\u884c\u64cd\u4f5c\u3002\u8fd9\u4f7f\u5f97Python3\u80fd\u591f\u9ad8\u6548\u5730\u5904\u7406\u5404\u79cd\u8bed\u8a00\u7684\u6587\u672c\uff0c\u5e76\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u5b57\u7b26\u4e32\u64cd\u4f5c\u65b9\u6cd5\u3002\u901a\u8fc7\u5145\u5206\u5229\u7528\u8fd9\u4e9b\u5de5\u5177\u548c\u65b9\u6cd5\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u8f7b\u677e\u5730\u5904\u7406\u590d\u6742\u7684\u6587\u672c\u5904\u7406\u4efb\u52a1\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5728Python3\u4e2d\uff0c\u5b57\u7b26\u4e0e\u5b57\u7b26\u4e32\u6709\u4ec0\u4e48\u533a\u522b\uff1f<\/strong><br \/>\u5728Python3\u4e2d\uff0c\u5b57\u7b26\u5b9e\u9645\u4e0a\u662f\u5b57\u7b26\u4e32\u7684\u4e00\u4e2a\u5b50\u96c6\u3002\u6bcf\u4e2a\u5b57\u7b26\u90fd\u53ef\u4ee5\u88ab\u89c6\u4e3a\u4e00\u4e2a\u957f\u5ea6\u4e3a1\u7684\u5b57\u7b26\u4e32\u3002\u56e0\u6b64\uff0c\u5b57\u7b26\u7684\u64cd\u4f5c\u5927\u591a\u4e0e\u5b57\u7b26\u4e32\u76f8\u540c\u3002\u6bd4\u5982\uff0c\u8bbf\u95ee\u5355\u4e2a\u5b57\u7b26\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528\u7d22\u5f15\u6765\u83b7\u53d6\u5b57\u7b26\u4e32\u4e2d\u7684\u67d0\u4e2a\u5b57\u7b26\u3002<\/p>\n<p><strong>Python3\u662f\u5982\u4f55\u5b58\u50a8\u5b57\u7b26\u7684\uff1f<\/strong><br \/>Python3\u4f7f\u7528Unicode\u6765\u5b58\u50a8\u5b57\u7b26\uff0c\u8fd9\u610f\u5473\u7740\u5b83\u53ef\u4ee5\u5904\u7406\u5404\u79cd\u8bed\u8a00\u7684\u5b57\u7b26\u3002Unicode\u4e3a\u6bcf\u4e2a\u5b57\u7b26\u5206\u914d\u4e00\u4e2a\u552f\u4e00\u7684\u4ee3\u7801\u70b9\uff0c\u4f7f\u5f97\u5728\u5904\u7406\u56fd\u9645\u5316\u6587\u672c\u65f6\u66f4\u52a0\u65b9\u4fbf\u3002Python3\u4e2d\u7684\u5b57\u7b26\u4e32\u7c7b\u578b\uff08str\uff09\u662f\u4ee5Unicode\u7f16\u7801\u7684\uff0c\u5141\u8bb8\u7528\u6237\u8f7b\u677e\u5904\u7406\u591a\u79cd\u8bed\u8a00\u7684\u6587\u672c\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728Python3\u4e2d\u5904\u7406\u5b57\u7b26\u548c\u5b57\u7b26\u4e32\u7684\u8f6c\u6362\uff1f<\/strong><br \/>\u5728Python3\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u5185\u7f6e\u7684\u51fd\u6570\u5c06\u5b57\u7b26\u8f6c\u6362\u4e3a\u5176\u4ed6\u6570\u636e\u7c7b\u578b\u3002\u4f8b\u5982\uff0c\u4f7f\u7528<code>ord()<\/code>\u51fd\u6570\u53ef\u4ee5\u83b7\u53d6\u5b57\u7b26\u7684Unicode\u7801\u70b9\uff0c\u800c\u4f7f\u7528<code>chr()<\/code>\u51fd\u6570\u5219\u53ef\u4ee5\u6839\u636eUnicode\u7801\u70b9\u8fd4\u56de\u76f8\u5e94\u7684\u5b57\u7b26\u3002\u6b64\u5916\uff0c\u5b57\u7b26\u4e32\u8fd8\u53ef\u4ee5\u901a\u8fc7\u5207\u7247\u548c\u62fc\u63a5\u7b49\u64cd\u4f5c\u8f7b\u677e\u8f6c\u6362\u6210\u5176\u4ed6\u5f62\u5f0f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python3\u4e2d\uff0c\u5b57\u7b26\u662f\u901a\u8fc7Unicode\u7f16\u7801\u5b9e\u73b0\u7684\u3001\u6bcf\u4e2a\u5b57\u7b26\u5360\u7528\u7684\u5b57\u8282\u6570\u662f\u52a8\u6001\u7684\u3001\u53ef\u4ee5\u901a\u8fc7\u5185\u7f6e\u51fd\u6570\u548c\u6a21\u5757\u8fdb [&hellip;]","protected":false},"author":3,"featured_media":1104632,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1104624"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=1104624"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1104624\/revisions"}],"predecessor-version":[{"id":1104634,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1104624\/revisions\/1104634"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1104632"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1104624"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1104624"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1104624"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}