{"id":1169937,"date":"2025-01-15T16:16:28","date_gmt":"2025-01-15T08:16:28","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1169937.html"},"modified":"2025-01-15T16:16:30","modified_gmt":"2025-01-15T08:16:30","slug":"python%e5%a6%82%e4%bd%95%e6%8a%8a%e6%b1%89%e5%ad%97%e5%8f%98%e4%b8%ba%e6%8b%bc%e9%9f%b3","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1169937.html","title":{"rendered":"python\u5982\u4f55\u628a\u6c49\u5b57\u53d8\u4e3a\u62fc\u97f3"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/26070739\/7214ad07-c44c-4207-a9b4-bd1ad03fafa7.webp\" alt=\"python\u5982\u4f55\u628a\u6c49\u5b57\u53d8\u4e3a\u62fc\u97f3\" \/><\/p>\n<p><p> \u8981\u5c06\u6c49\u5b57\u8f6c\u6362\u4e3a\u62fc\u97f3\uff0c\u53ef\u4ee5\u4f7f\u7528Python\u4e2d\u7684\u4e00\u4e9b\u7b2c\u4e09\u65b9\u5e93\uff0c\u4f8b\u5982<code>pypinyin<\/code>\u3001<code>xpinyin<\/code>\u7b49\u3002<strong>\u4f7f\u7528<code>pypinyin<\/code>\u5e93\u8f6c\u6362\u6c49\u5b57\u4e3a\u62fc\u97f3\u975e\u5e38\u65b9\u4fbf\u3001\u53ef\u4ee5\u5904\u7406\u591a\u97f3\u5b57\u3001\u652f\u6301\u62fc\u97f3\u97f3\u8c03\u7b49\u529f\u80fd<\/strong>\u3002\u4e0b\u9762\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528<code>pypinyin<\/code>\u5e93\u5b9e\u73b0\u6c49\u5b57\u5230\u62fc\u97f3\u7684\u8f6c\u6362\u3002<\/p>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u9700\u8981\u5b89\u88c5<code>pypinyin<\/code>\u5e93\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install pypinyin<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u5c06\u6c49\u5b57\u8f6c\u6362\u4e3a\u62fc\u97f3\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from pypinyin import pinyin, lazy_pinyin, Style<\/p>\n<h2><strong>\u793a\u4f8b\u6c49\u5b57<\/strong><\/h2>\n<p>chinese_text = &quot;\u4f60\u597d\uff0c\u4e16\u754c\uff01&quot;<\/p>\n<h2><strong>\u4f7f\u7528pinyin\u51fd\u6570\uff0c\u8fd4\u56de\u5305\u542b\u97f3\u8c03\u7684\u62fc\u97f3<\/strong><\/h2>\n<p>pinyin_with_tone = pinyin(chinese_text, style=Style.TONE)<\/p>\n<p>print(&quot;\u5e26\u97f3\u8c03\u7684\u62fc\u97f3\uff1a&quot;, pinyin_with_tone)<\/p>\n<h2><strong>\u4f7f\u7528lazy_pinyin\u51fd\u6570\uff0c\u8fd4\u56de\u4e0d\u5305\u542b\u97f3\u8c03\u7684\u62fc\u97f3<\/strong><\/h2>\n<p>pinyin_without_tone = lazy_pinyin(chinese_text)<\/p>\n<p>print(&quot;\u4e0d\u5e26\u97f3\u8c03\u7684\u62fc\u97f3\uff1a&quot;, pinyin_without_tone)<\/p>\n<h2><strong>\u5c06\u62fc\u97f3\u5217\u8868\u8f6c\u4e3a\u5b57\u7b26\u4e32<\/strong><\/h2>\n<p>pinyin_str_with_tone = &#39; &#39;.join([item[0] for item in pinyin_with_tone])<\/p>\n<p>pinyin_str_without_tone = &#39; &#39;.join(pinyin_without_tone)<\/p>\n<p>print(&quot;\u5e26\u97f3\u8c03\u7684\u62fc\u97f3\u5b57\u7b26\u4e32\uff1a&quot;, pinyin_str_with_tone)<\/p>\n<p>print(&quot;\u4e0d\u5e26\u97f3\u8c03\u7684\u62fc\u97f3\u5b57\u7b26\u4e32\uff1a&quot;, pinyin_str_without_tone)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4ee5\u4e0a\u4ee3\u7801\u9996\u5148\u5bfc\u5165\u4e86<code>pypinyin<\/code>\u5e93\u4e2d\u7684<code>pinyin<\/code>\u3001<code>lazy_pinyin<\/code>\u548c<code>Style<\/code>\u6a21\u5757\uff0c\u7136\u540e\u901a\u8fc7<code>pinyin<\/code>\u51fd\u6570\u5c06\u6c49\u5b57\u8f6c\u6362\u4e3a\u5e26\u6709\u97f3\u8c03\u7684\u62fc\u97f3\uff0c\u901a\u8fc7<code>lazy_pinyin<\/code>\u51fd\u6570\u5c06\u6c49\u5b57\u8f6c\u6362\u4e3a\u4e0d\u5e26\u97f3\u8c03\u7684\u62fc\u97f3\u3002\u6700\u540e\uff0c\u5c06\u62fc\u97f3\u5217\u8868\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\u5e76\u6253\u5370\u51fa\u6765\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u4f7f\u7528pypinyin\u5e93\u5904\u7406\u591a\u97f3\u5b57<\/h3>\n<\/p>\n<p><p><code>pypinyin<\/code>\u5e93\u5728\u5904\u7406\u591a\u97f3\u5b57\u65b9\u9762\u4e5f\u6709\u975e\u5e38\u597d\u7684\u652f\u6301\u3002\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e<code>heteronym<\/code>\u53c2\u6570\u4e3a<code>True<\/code>\u6765\u83b7\u53d6\u591a\u97f3\u5b57\u7684\u6240\u6709\u62fc\u97f3\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from pypinyin import pinyin, Style<\/p>\n<h2><strong>\u793a\u4f8b\u6c49\u5b57<\/strong><\/h2>\n<p>chinese_text = &quot;\u91cd\u9633\u8282&quot;<\/p>\n<h2><strong>\u83b7\u53d6\u591a\u97f3\u5b57\u7684\u6240\u6709\u62fc\u97f3<\/strong><\/h2>\n<p>pinyin_with_heteronym = pinyin(chinese_text, style=Style.TONE, heteronym=True)<\/p>\n<p>print(&quot;\u591a\u97f3\u5b57\u62fc\u97f3\uff1a&quot;, pinyin_with_heteronym)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c<code>\u91cd<\/code>\u5b57\u6709\u4e24\u4e2a\u62fc\u97f3<code>zh\u00f2ng<\/code>\u548c<code>ch\u00f3ng<\/code>\uff0c\u901a\u8fc7\u8bbe\u7f6e<code>heteronym=True<\/code>\uff0c\u53ef\u4ee5\u83b7\u53d6\u6240\u6709\u53ef\u80fd\u7684\u62fc\u97f3\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u4f7f\u7528pypinyin\u5e93\u5904\u7406\u58f0\u6bcd\u548c\u97f5\u6bcd<\/h3>\n<\/p>\n<p><p><code>pypinyin<\/code>\u5e93\u8fd8\u53ef\u4ee5\u5206\u522b\u63d0\u53d6\u6c49\u5b57\u7684\u58f0\u6bcd\u548c\u97f5\u6bcd\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from pypinyin import pinyin, Style<\/p>\n<h2><strong>\u793a\u4f8b\u6c49\u5b57<\/strong><\/h2>\n<p>chinese_text = &quot;\u4f60\u597d&quot;<\/p>\n<h2><strong>\u83b7\u53d6\u58f0\u6bcd<\/strong><\/h2>\n<p>initials = pinyin(chinese_text, style=Style.INITIALS)<\/p>\n<p>print(&quot;\u58f0\u6bcd\uff1a&quot;, initials)<\/p>\n<h2><strong>\u83b7\u53d6\u97f5\u6bcd<\/strong><\/h2>\n<p>finals = pinyin(chinese_text, style=Style.FINALS)<\/p>\n<p>print(&quot;\u97f5\u6bcd\uff1a&quot;, finals)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c<code>\u4f60\u597d<\/code>\u7684\u58f0\u6bcd\u5206\u522b\u662f<code>n<\/code>\u548c<code>h<\/code>\uff0c\u97f5\u6bcd\u5206\u522b\u662f<code>i<\/code>\u548c<code>ao<\/code>\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u4f7f\u7528pypinyin\u5e93\u5904\u7406\u4e0d\u540c\u62fc\u97f3\u98ce\u683c<\/h3>\n<\/p>\n<p><p><code>pypinyin<\/code>\u5e93\u652f\u6301\u591a\u79cd\u62fc\u97f3\u98ce\u683c\uff0c\u4f8b\u5982\u5e26\u97f3\u8c03\u7684\u62fc\u97f3\uff08<code>TONE<\/code>\uff09\u3001\u4e0d\u5e26\u97f3\u8c03\u7684\u62fc\u97f3\uff08<code>NORMAL<\/code>\uff09\u3001\u58f0\u6bcd\uff08<code>INITIALS<\/code>\uff09\u3001\u97f5\u6bcd\uff08<code>FINALS<\/code>\uff09\u3001\u97f3\u8c03\u6570\u5b57\u8868\u793a\u6cd5\uff08<code>TONE2<\/code>\uff09\u7b49\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from pypinyin import pinyin, Style<\/p>\n<h2><strong>\u793a\u4f8b\u6c49\u5b57<\/strong><\/h2>\n<p>chinese_text = &quot;\u4f60\u597d&quot;<\/p>\n<h2><strong>\u5e26\u97f3\u8c03\u7684\u62fc\u97f3<\/strong><\/h2>\n<p>pinyin_with_tone = pinyin(chinese_text, style=Style.TONE)<\/p>\n<p>print(&quot;\u5e26\u97f3\u8c03\u7684\u62fc\u97f3\uff1a&quot;, pinyin_with_tone)<\/p>\n<h2><strong>\u4e0d\u5e26\u97f3\u8c03\u7684\u62fc\u97f3<\/strong><\/h2>\n<p>pinyin_without_tone = pinyin(chinese_text, style=Style.NORMAL)<\/p>\n<p>print(&quot;\u4e0d\u5e26\u97f3\u8c03\u7684\u62fc\u97f3\uff1a&quot;, pinyin_without_tone)<\/p>\n<h2><strong>\u97f3\u8c03\u6570\u5b57\u8868\u793a\u6cd5<\/strong><\/h2>\n<p>pinyin_with_tone2 = pinyin(chinese_text, style=Style.TONE2)<\/p>\n<p>print(&quot;\u97f3\u8c03\u6570\u5b57\u8868\u793a\u6cd5\uff1a&quot;, pinyin_with_tone2)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c<code>\u4f60\u597d<\/code>\u7684\u5e26\u97f3\u8c03\u62fc\u97f3\u662f<code>n\u01d0 h\u01ceo<\/code>\uff0c\u4e0d\u5e26\u97f3\u8c03\u7684\u62fc\u97f3\u662f<code>ni hao<\/code>\uff0c\u97f3\u8c03\u6570\u5b57\u8868\u793a\u6cd5\u662f<code>ni3 hao3<\/code>\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u4f7f\u7528pypinyin\u5e93\u5904\u7406\u7279\u6b8a\u5b57\u7b26\u548c\u6807\u70b9\u7b26\u53f7<\/h3>\n<\/p>\n<p><p>\u5728\u5904\u7406\u6c49\u5b57\u65f6\uff0c\u5f80\u5f80\u4f1a\u9047\u5230\u4e00\u4e9b\u7279\u6b8a\u5b57\u7b26\u548c\u6807\u70b9\u7b26\u53f7\u3002<code>pypinyin<\/code>\u5e93\u53ef\u4ee5\u5f88\u597d\u5730\u5904\u7406\u8fd9\u4e9b\u60c5\u51b5\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from pypinyin import pinyin<\/p>\n<h2><strong>\u793a\u4f8b\u6c49\u5b57<\/strong><\/h2>\n<p>chinese_text = &quot;\u4f60\u597d\uff0c\u4e16\u754c\uff01&quot;<\/p>\n<h2><strong>\u5904\u7406\u7279\u6b8a\u5b57\u7b26\u548c\u6807\u70b9\u7b26\u53f7<\/strong><\/h2>\n<p>pinyin_with_special_chars = pinyin(chinese_text)<\/p>\n<p>print(&quot;\u62fc\u97f3\uff08\u5305\u542b\u7279\u6b8a\u5b57\u7b26\u548c\u6807\u70b9\u7b26\u53f7\uff09\uff1a&quot;, pinyin_with_special_chars)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c<code>\u4f60\u597d\uff0c\u4e16\u754c\uff01<\/code>\u4e2d\u7684\u6807\u70b9\u7b26\u53f7\u4e0d\u4f1a\u88ab\u8f6c\u6362\u4e3a\u62fc\u97f3\uff0c\u7ed3\u679c\u4e3a<code>[[&#39;n\u01d0&#39;], [&#39;h\u01ceo&#39;], [&#39;\uff0c&#39;], [&#39;sh\u00ec&#39;], [&#39;ji\u00e8&#39;], [&#39;\uff01&#39;]]<\/code>\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001\u4f7f\u7528pypinyin\u5e93\u5904\u7406\u4e0d\u540c\u5730\u533a\u7684\u62fc\u97f3<\/h3>\n<\/p>\n<p><p>\u4e0d\u540c\u5730\u533a\u7684\u62fc\u97f3\u5728\u67d0\u4e9b\u53d1\u97f3\u4e0a\u53ef\u80fd\u5b58\u5728\u5dee\u5f02\u3002<code>pypinyin<\/code>\u5e93\u63d0\u4f9b\u4e86\u5bf9\u4e0d\u540c\u5730\u533a\u62fc\u97f3\u7684\u652f\u6301\u3002\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e<code>strict<\/code>\u53c2\u6570\u6765\u63a7\u5236\u662f\u5426\u4e25\u683c\u6309\u7167\u6807\u51c6\u62fc\u97f3\u89c4\u5219\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from pypinyin import pinyin, Style<\/p>\n<h2><strong>\u793a\u4f8b\u6c49\u5b57<\/strong><\/h2>\n<p>chinese_text = &quot;\u91cd\u5e86&quot;<\/p>\n<h2><strong>\u4e25\u683c\u6309\u7167\u6807\u51c6\u62fc\u97f3\u89c4\u5219<\/strong><\/h2>\n<p>strict_pinyin = pinyin(chinese_text, style=Style.TONE, strict=True)<\/p>\n<p>print(&quot;\u4e25\u683c\u62fc\u97f3\uff1a&quot;, strict_pinyin)<\/p>\n<h2><strong>\u975e\u4e25\u683c\u62fc\u97f3<\/strong><\/h2>\n<p>non_strict_pinyin = pinyin(chinese_text, style=Style.TONE, strict=False)<\/p>\n<p>print(&quot;\u975e\u4e25\u683c\u62fc\u97f3\uff1a&quot;, non_strict_pinyin)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c<code>\u91cd\u5e86<\/code>\u5728\u4e25\u683c\u62fc\u97f3\u89c4\u5219\u4e0b\u7684\u62fc\u97f3\u662f<code>zh\u00f2ng q\u00ecng<\/code>\uff0c\u800c\u5728\u975e\u4e25\u683c\u62fc\u97f3\u89c4\u5219\u4e0b\u7684\u62fc\u97f3\u662f<code>ch\u00f3ng q\u00ecng<\/code>\u3002<\/p>\n<\/p>\n<p><h3>\u516d\u3001\u5904\u7406\u62fc\u97f3\u4e2d\u7684\u5b57\u6bcd\u95f4\u9694<\/h3>\n<\/p>\n<p><p>\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u6709\u65f6\u5019\u9700\u8981\u5c06\u62fc\u97f3\u4e2d\u7684\u5b57\u6bcd\u7528\u7279\u5b9a\u7684\u5b57\u7b26\u8fdb\u884c\u95f4\u9694\uff0c\u4ee5\u4fbf\u66f4\u597d\u5730\u5c55\u793a\u3002<code>pypinyin<\/code>\u5e93\u63d0\u4f9b\u4e86\u7075\u6d3b\u7684\u62fc\u97f3\u683c\u5f0f\u63a7\u5236\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from pypinyin import pinyin, lazy_pinyin, Style<\/p>\n<h2><strong>\u793a\u4f8b\u6c49\u5b57<\/strong><\/h2>\n<p>chinese_text = &quot;\u6c49\u5b57\u62fc\u97f3&quot;<\/p>\n<h2><strong>\u4f7f\u7528\u7a7a\u683c\u95f4\u9694\u62fc\u97f3\u5b57\u6bcd<\/strong><\/h2>\n<p>pinyin_with_spaces = pinyin(chinese_text, style=Style.TONE, separator=&#39; &#39;)<\/p>\n<p>print(&quot;\u62fc\u97f3\uff08\u7a7a\u683c\u95f4\u9694\uff09\uff1a&quot;, pinyin_with_spaces)<\/p>\n<h2><strong>\u4f7f\u7528\u8fde\u5b57\u7b26\u95f4\u9694\u62fc\u97f3\u5b57\u6bcd<\/strong><\/h2>\n<p>pinyin_with_hyphens = pinyin(chinese_text, style=Style.TONE, separator=&#39;-&#39;)<\/p>\n<p>print(&quot;\u62fc\u97f3\uff08\u8fde\u5b57\u7b26\u95f4\u9694\uff09\uff1a&quot;, pinyin_with_hyphens)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c<code>\u6c49\u5b57\u62fc\u97f3<\/code>\u7684\u62fc\u97f3\u53ef\u4ee5\u7528\u7a7a\u683c\u6216\u8fde\u5b57\u7b26\u8fdb\u884c\u95f4\u9694\u3002<\/p>\n<\/p>\n<p><h3>\u4e03\u3001\u4f7f\u7528pypinyin\u5e93\u5904\u7406\u62fc\u97f3\u7684\u5927\u5c0f\u5199<\/h3>\n<\/p>\n<p><p>\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u6709\u65f6\u9700\u8981\u5c06\u62fc\u97f3\u8f6c\u6362\u4e3a\u5927\u5199\u6216\u5c0f\u5199\u3002<code>pypinyin<\/code>\u5e93\u63d0\u4f9b\u4e86\u5bf9\u62fc\u97f3\u5927\u5c0f\u5199\u7684\u652f\u6301\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from pypinyin import lazy_pinyin<\/p>\n<h2><strong>\u793a\u4f8b\u6c49\u5b57<\/strong><\/h2>\n<p>chinese_text = &quot;\u6c49\u5b57\u62fc\u97f3&quot;<\/p>\n<h2><strong>\u5c0f\u5199\u62fc\u97f3<\/strong><\/h2>\n<p>pinyin_lowercase = lazy_pinyin(chinese_text)<\/p>\n<p>print(&quot;\u5c0f\u5199\u62fc\u97f3\uff1a&quot;, pinyin_lowercase)<\/p>\n<h2><strong>\u5927\u5199\u62fc\u97f3<\/strong><\/h2>\n<p>pinyin_uppercase = lazy_pinyin(chinese_text, style=None, errors=&#39;ignore&#39;, strict=False)<\/p>\n<p>pinyin_uppercase = [py.upper() for py in pinyin_uppercase]<\/p>\n<p>print(&quot;\u5927\u5199\u62fc\u97f3\uff1a&quot;, pinyin_uppercase)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c<code>\u6c49\u5b57\u62fc\u97f3<\/code>\u7684\u62fc\u97f3\u5206\u522b\u8f6c\u6362\u4e3a\u5c0f\u5199\u548c\u5927\u5199\u3002<\/p>\n<\/p>\n<p><h3>\u516b\u3001\u4f7f\u7528pypinyin\u5e93\u5904\u7406\u6c49\u5b57\u62fc\u97f3\u9996\u5b57\u6bcd<\/h3>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u5e94\u7528\u573a\u666f\u4e2d\uff0c\u53ef\u80fd\u53ea\u9700\u8981\u83b7\u53d6\u6c49\u5b57\u7684\u62fc\u97f3\u9996\u5b57\u6bcd\u3002<code>pypinyin<\/code>\u5e93\u63d0\u4f9b\u4e86\u5bf9\u62fc\u97f3\u9996\u5b57\u6bcd\u7684\u652f\u6301\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from pypinyin import lazy_pinyin, Style<\/p>\n<h2><strong>\u793a\u4f8b\u6c49\u5b57<\/strong><\/h2>\n<p>chinese_text = &quot;\u6c49\u5b57\u62fc\u97f3&quot;<\/p>\n<h2><strong>\u83b7\u53d6\u62fc\u97f3\u9996\u5b57\u6bcd<\/strong><\/h2>\n<p>pinyin_initials = lazy_pinyin(chinese_text, style=Style.FIRST_LETTER)<\/p>\n<p>print(&quot;\u62fc\u97f3\u9996\u5b57\u6bcd\uff1a&quot;, pinyin_initials)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c<code>\u6c49\u5b57\u62fc\u97f3<\/code>\u7684\u62fc\u97f3\u9996\u5b57\u6bcd\u4e3a<code>[&#39;h&#39;, &#39;z&#39;, &#39;p&#39;, &#39;y&#39;]<\/code>\u3002<\/p>\n<\/p>\n<p><h3>\u4e5d\u3001\u4f7f\u7528pypinyin\u5e93\u5904\u7406\u81ea\u5b9a\u4e49\u62fc\u97f3\u8bcd\u5178<\/h3>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u7279\u6b8a\u573a\u666f\u4e0b\uff0c\u53ef\u80fd\u9700\u8981\u81ea\u5b9a\u4e49\u62fc\u97f3\u8bcd\u5178\u3002<code>pypinyin<\/code>\u5e93\u5141\u8bb8\u7528\u6237\u81ea\u5b9a\u4e49\u62fc\u97f3\u8bcd\u5178\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from pypinyin import pinyin, lazy_pinyin, Style, load_phrases_dict<\/p>\n<h2><strong>\u81ea\u5b9a\u4e49\u62fc\u97f3\u8bcd\u5178<\/strong><\/h2>\n<p>custom_dict = {<\/p>\n<p>    &#39;\u91cd\u9633\u8282&#39;: [[&#39;ch\u00f3ng&#39;], [&#39;y\u00e1ng&#39;], [&#39;ji\u00e9&#39;]]<\/p>\n<p>}<\/p>\n<h2><strong>\u52a0\u8f7d\u81ea\u5b9a\u4e49\u62fc\u97f3\u8bcd\u5178<\/strong><\/h2>\n<p>load_phrases_dict(custom_dict)<\/p>\n<h2><strong>\u793a\u4f8b\u6c49\u5b57<\/strong><\/h2>\n<p>chinese_text = &quot;\u91cd\u9633\u8282&quot;<\/p>\n<h2><strong>\u4f7f\u7528\u81ea\u5b9a\u4e49\u62fc\u97f3\u8bcd\u5178\u8fdb\u884c\u62fc\u97f3\u8f6c\u6362<\/strong><\/h2>\n<p>pinyin_custom = pinyin(chinese_text, style=Style.TONE)<\/p>\n<p>print(&quot;\u81ea\u5b9a\u4e49\u62fc\u97f3\uff1a&quot;, pinyin_custom)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u81ea\u5b9a\u4e49\u4e86<code>\u91cd\u9633\u8282<\/code>\u7684\u62fc\u97f3\u4e3a<code>ch\u00f3ng y\u00e1ng ji\u00e9<\/code>\u3002<\/p>\n<\/p>\n<p><h3>\u5341\u3001\u4f7f\u7528pypinyin\u5e93\u5904\u7406\u62fc\u97f3\u4e2d\u7684\u9519\u8bef<\/h3>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u65e0\u6cd5\u8f6c\u6362\u4e3a\u62fc\u97f3\u7684\u6c49\u5b57\u3002<code>pypinyin<\/code>\u5e93\u63d0\u4f9b\u4e86\u5bf9\u62fc\u97f3\u8f6c\u6362\u9519\u8bef\u7684\u5904\u7406\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from pypinyin import lazy_pinyin<\/p>\n<h2><strong>\u793a\u4f8b\u6c49\u5b57\uff08\u5305\u542b\u65e0\u6cd5\u8f6c\u6362\u7684\u5b57\u7b26\uff09<\/strong><\/h2>\n<p>chinese_text = &quot;\u4f60\u597d\uff0c\u4e16\u754c\uff01123&quot;<\/p>\n<h2><strong>\u5904\u7406\u62fc\u97f3\u8f6c\u6362\u9519\u8bef<\/strong><\/h2>\n<p>pinyin_with_errors = lazy_pinyin(chinese_text, errors=&#39;default&#39;)<\/p>\n<p>print(&quot;\u62fc\u97f3\uff08\u5904\u7406\u9519\u8bef\uff09\uff1a&quot;, pinyin_with_errors)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u65e0\u6cd5\u8f6c\u6362\u4e3a\u62fc\u97f3\u7684\u5b57\u7b26\u4f1a\u539f\u6837\u4fdd\u7559\u3002<\/p>\n<\/p>\n<p><h3>\u5341\u4e00\u3001\u4f7f\u7528pypinyin\u5e93\u5904\u7406\u5e26\u97f3\u8c03\u7684\u62fc\u97f3<\/h3>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u5e94\u7528\u573a\u666f\u4e2d\uff0c\u9700\u8981\u83b7\u53d6\u5e26\u97f3\u8c03\u7684\u62fc\u97f3\u3002<code>pypinyin<\/code>\u5e93\u63d0\u4f9b\u4e86\u5bf9\u5e26\u97f3\u8c03\u62fc\u97f3\u7684\u652f\u6301\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from pypinyin import pinyin, Style<\/p>\n<h2><strong>\u793a\u4f8b\u6c49\u5b57<\/strong><\/h2>\n<p>chinese_text = &quot;\u4f60\u597d&quot;<\/p>\n<h2><strong>\u83b7\u53d6\u5e26\u97f3\u8c03\u7684\u62fc\u97f3<\/strong><\/h2>\n<p>pinyin_with_tone = pinyin(chinese_text, style=Style.TONE)<\/p>\n<p>print(&quot;\u5e26\u97f3\u8c03\u7684\u62fc\u97f3\uff1a&quot;, pinyin_with_tone)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c<code>\u4f60\u597d<\/code>\u7684\u5e26\u97f3\u8c03\u62fc\u97f3\u4e3a<code>[[&#39;n\u01d0&#39;], [&#39;h\u01ceo&#39;]]<\/code>\u3002<\/p>\n<\/p>\n<p><h3>\u5341\u4e8c\u3001\u4f7f\u7528pypinyin\u5e93\u5904\u7406\u4e0d\u5e26\u97f3\u8c03\u7684\u62fc\u97f3<\/h3>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u5e94\u7528\u573a\u666f\u4e2d\uff0c\u9700\u8981\u83b7\u53d6\u4e0d\u5e26\u97f3\u8c03\u7684\u62fc\u97f3\u3002<code>pypinyin<\/code>\u5e93\u63d0\u4f9b\u4e86\u5bf9\u4e0d\u5e26\u97f3\u8c03\u62fc\u97f3\u7684\u652f\u6301\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from pypinyin import lazy_pinyin<\/p>\n<h2><strong>\u793a\u4f8b\u6c49\u5b57<\/strong><\/h2>\n<p>chinese_text = &quot;\u4f60\u597d&quot;<\/p>\n<h2><strong>\u83b7\u53d6\u4e0d\u5e26\u97f3\u8c03\u7684\u62fc\u97f3<\/strong><\/h2>\n<p>pinyin_without_tone = lazy_pinyin(chinese_text)<\/p>\n<p>print(&quot;\u4e0d\u5e26\u97f3\u8c03\u7684\u62fc\u97f3\uff1a&quot;, pinyin_without_tone)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c<code>\u4f60\u597d<\/code>\u7684\u4e0d\u5e26\u97f3\u8c03\u62fc\u97f3\u4e3a<code>[&#39;ni&#39;, &#39;hao&#39;]<\/code>\u3002<\/p>\n<\/p>\n<p><h3>\u5341\u4e09\u3001\u4f7f\u7528pypinyin\u5e93\u5904\u7406\u62fc\u97f3\u97f3\u8c03\u6570\u5b57\u8868\u793a\u6cd5<\/h3>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u5e94\u7528\u573a\u666f\u4e2d\uff0c\u9700\u8981\u4f7f\u7528\u97f3\u8c03\u6570\u5b57\u8868\u793a\u6cd5\u6765\u8868\u793a\u62fc\u97f3\u3002<code>pypinyin<\/code>\u5e93\u63d0\u4f9b\u4e86\u5bf9\u97f3\u8c03\u6570\u5b57\u8868\u793a\u6cd5\u7684\u652f\u6301\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from pypinyin import pinyin, Style<\/p>\n<h2><strong>\u793a\u4f8b\u6c49\u5b57<\/strong><\/h2>\n<p>chinese_text = &quot;\u4f60\u597d&quot;<\/p>\n<h2><strong>\u83b7\u53d6\u97f3\u8c03\u6570\u5b57\u8868\u793a\u6cd5\u7684\u62fc\u97f3<\/strong><\/h2>\n<p>pinyin_with_tone2 = pinyin(chinese_text, style=Style.TONE2)<\/p>\n<p>print(&quot;\u97f3\u8c03\u6570\u5b57\u8868\u793a\u6cd5\u7684\u62fc\u97f3\uff1a&quot;, pinyin_with_tone2)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c<code>\u4f60\u597d<\/code>\u7684\u97f3\u8c03\u6570\u5b57\u8868\u793a\u6cd5\u62fc\u97f3\u4e3a<code>[[&#39;ni3&#39;], [&#39;hao3&#39;]]<\/code>\u3002<\/p>\n<\/p>\n<p><h3>\u5341\u56db\u3001\u4f7f\u7528pypinyin\u5e93\u5904\u7406\u62fc\u97f3\u97f3\u8c03\u6807\u8bb0\u6cd5<\/h3>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u5e94\u7528\u573a\u666f\u4e2d\uff0c\u9700\u8981\u4f7f\u7528\u97f3\u8c03\u6807\u8bb0\u6cd5\u6765\u8868\u793a\u62fc\u97f3\u3002<code>pypinyin<\/code>\u5e93\u63d0\u4f9b\u4e86\u5bf9\u97f3\u8c03\u6807\u8bb0\u6cd5\u7684\u652f\u6301\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from pypinyin import pinyin, Style<\/p>\n<h2><strong>\u793a\u4f8b\u6c49\u5b57<\/strong><\/h2>\n<p>chinese_text = &quot;\u4f60\u597d&quot;<\/p>\n<h2><strong>\u83b7\u53d6\u97f3\u8c03\u6807\u8bb0\u6cd5\u7684\u62fc\u97f3<\/strong><\/h2>\n<p>pinyin_with_tone3 = pinyin(chinese_text, style=Style.TONE3)<\/p>\n<p>print(&quot;\u97f3\u8c03\u6807\u8bb0\u6cd5\u7684\u62fc\u97f3\uff1a&quot;, pinyin_with_tone3)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c<code>\u4f60\u597d<\/code>\u7684\u97f3\u8c03\u6807\u8bb0\u6cd5\u62fc\u97f3\u4e3a<code>[[&#39;ni3&#39;], [&#39;hao3&#39;]]<\/code>\u3002<\/p>\n<\/p>\n<p><h3>\u5341\u4e94\u3001\u4f7f\u7528pypinyin\u5e93\u5904\u7406\u62fc\u97f3\u97f3\u8c03\u4f4d\u7f6e<\/h3>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u5e94\u7528\u573a\u666f\u4e2d\uff0c\u9700\u8981\u63a7\u5236\u62fc\u97f3\u97f3\u8c03\u7684\u4f4d\u7f6e\u3002<code>pypinyin<\/code>\u5e93\u63d0\u4f9b\u4e86\u5bf9\u62fc\u97f3\u97f3\u8c03\u4f4d\u7f6e\u7684\u652f\u6301\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from pypinyin import pinyin, Style<\/p>\n<h2><strong>\u793a\u4f8b\u6c49\u5b57<\/strong><\/h2>\n<p>chinese_text = &quot;\u4f60\u597d&quot;<\/p>\n<h2><strong>\u83b7\u53d6\u62fc\u97f3\u97f3\u8c03\u4f4d\u7f6e<\/strong><\/h2>\n<p>pinyin_with_tone_position = pinyin(chinese_text, style=Style.TONE3)<\/p>\n<p>print(&quot;\u62fc\u97f3\u97f3\u8c03\u4f4d\u7f6e\uff1a&quot;, pinyin_with_tone_position)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c<code>\u4f60\u597d<\/code>\u7684\u62fc\u97f3\u97f3\u8c03\u4f4d\u7f6e\u4e3a<code>[[&#39;ni3&#39;], [&#39;hao3&#39;]]<\/code>\u3002<\/p>\n<\/p>\n<p><h3>\u5341\u516d\u3001\u4f7f\u7528pypinyin\u5e93\u5904\u7406\u62fc\u97f3\u97f3\u8c03\u7c7b\u578b<\/h3>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u5e94\u7528\u573a\u666f\u4e2d\uff0c\u9700\u8981\u63a7\u5236\u62fc\u97f3\u97f3\u8c03\u7684\u7c7b\u578b\u3002<code>pypinyin<\/code>\u5e93\u63d0\u4f9b\u4e86\u5bf9\u62fc\u97f3\u97f3\u8c03\u7c7b\u578b\u7684\u652f\u6301\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from pypinyin import pinyin, Style<\/p>\n<h2><strong>\u793a\u4f8b\u6c49\u5b57<\/strong><\/h2>\n<p>chinese_text = &quot;\u4f60\u597d&quot;<\/p>\n<h2><strong>\u83b7\u53d6\u62fc\u97f3\u97f3\u8c03\u7c7b\u578b<\/strong><\/h2>\n<p>pinyin_with_tone_type = pinyin(chinese_text, style=Style.TONE3)<\/p>\n<p>print(&quot;\u62fc\u97f3\u97f3\u8c03\u7c7b\u578b\uff1a&quot;, pinyin_with_tone_type)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c<code>\u4f60\u597d<\/code>\u7684\u62fc\u97f3\u97f3\u8c03\u7c7b\u578b\u4e3a<code>[[&#39;ni3&#39;], [&#39;hao3&#39;]]<\/code>\u3002<\/p>\n<\/p>\n<p><h3>\u5341\u4e03\u3001\u4f7f\u7528pypinyin\u5e93\u5904\u7406\u62fc\u97f3\u97f3\u8c03\u89c4\u5219<\/h3>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u5e94\u7528\u573a\u666f\u4e2d\uff0c\u9700\u8981\u63a7\u5236\u62fc\u97f3\u97f3\u8c03\u7684\u89c4\u5219\u3002<code>pypinyin<\/code>\u5e93\u63d0\u4f9b\u4e86\u5bf9\u62fc\u97f3\u97f3\u8c03\u89c4\u5219\u7684\u652f\u6301\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from pypinyin import pinyin, Style<\/p>\n<h2><strong>\u793a\u4f8b\u6c49\u5b57<\/strong><\/h2>\n<p>chinese_text = &quot;\u4f60\u597d&quot;<\/p>\n<h2><strong>\u83b7\u53d6\u62fc\u97f3\u97f3\u8c03\u89c4\u5219<\/strong><\/h2>\n<p>pinyin_with_tone_rule = pinyin(chinese_text, style=Style.TONE3)<\/p>\n<p>print(&quot;\u62fc\u97f3\u97f3\u8c03\u89c4\u5219\uff1a&quot;, pinyin_with_tone_rule)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c<code>\u4f60\u597d<\/code>\u7684\u62fc\u97f3\u97f3\u8c03\u89c4\u5219\u4e3a<code>[[&#39;ni3&#39;], [&#39;hao3&#39;]]<\/code>\u3002<\/p>\n<\/p>\n<p><h3>\u5341\u516b\u3001\u4f7f\u7528pypinyin\u5e93\u5904\u7406\u62fc\u97f3\u97f3\u8c03\u5b57\u7b26<\/h3>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u5e94\u7528\u573a\u666f\u4e2d\uff0c\u9700\u8981\u63a7\u5236\u62fc\u97f3\u97f3\u8c03\u7684\u5b57\u7b26\u3002<code>pypinyin<\/code>\u5e93\u63d0\u4f9b\u4e86\u5bf9\u62fc\u97f3\u97f3\u8c03\u5b57\u7b26\u7684\u652f\u6301\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from pypinyin import pinyin, Style<\/p>\n<h2><strong>\u793a\u4f8b\u6c49\u5b57<\/strong><\/h2>\n<p>chinese_text = &quot;\u4f60\u597d&quot;<\/p>\n<h2><strong>\u83b7\u53d6\u62fc\u97f3\u97f3\u8c03\u5b57\u7b26<\/strong><\/h2>\n<p>pinyin_with_tone_char = pinyin(chinese_text, style=Style.TONE3)<\/p>\n<p>print(&quot;\u62fc\u97f3\u97f3\u8c03\u5b57\u7b26\uff1a&quot;, pinyin_with_tone_char)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c<code>\u4f60\u597d<\/code>\u7684\u62fc\u97f3\u97f3\u8c03\u5b57\u7b26\u4e3a<code>[[&#39;ni3&#39;], [&#39;hao3&#39;]]<\/code>\u3002<\/p>\n<\/p>\n<p><h3>\u5341\u4e5d\u3001\u4f7f\u7528pypinyin\u5e93\u5904\u7406\u62fc\u97f3\u97f3\u8c03\u7b26\u53f7<\/h3>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u5e94\u7528\u573a\u666f\u4e2d\uff0c\u9700\u8981\u63a7\u5236\u62fc\u97f3\u97f3\u8c03\u7684\u7b26\u53f7\u3002<code>pypinyin<\/code>\u5e93\u63d0\u4f9b\u4e86\u5bf9\u62fc\u97f3\u97f3\u8c03\u7b26\u53f7\u7684\u652f\u6301\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from pypinyin import pinyin, Style<\/p>\n<h2><strong>\u793a\u4f8b\u6c49\u5b57<\/strong><\/h2>\n<p>chinese_text = &quot;\u4f60\u597d&quot;<\/p>\n<h2><strong>\u83b7\u53d6\u62fc\u97f3\u97f3\u8c03\u7b26\u53f7<\/strong><\/h2>\n<p>pinyin_with_tone_symbol = pinyin(chinese_text, style=Style.TONE3)<\/p>\n<p>print(&quot;\u62fc\u97f3\u97f3\u8c03\u7b26\u53f7\uff1a&quot;, pinyin_with_tone_symbol)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c<code>\u4f60\u597d<\/code>\u7684\u62fc\u97f3\u97f3<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u4f7f\u7528Python\u5c06\u6c49\u5b57\u8f6c\u6362\u4e3a\u62fc\u97f3\uff1f<\/strong><br \/>\u8981\u5728Python\u4e2d\u5c06\u6c49\u5b57\u8f6c\u6362\u4e3a\u62fc\u97f3\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u7b2c\u4e09\u65b9\u5e93\u5982<code>pypinyin<\/code>\u3002\u5b89\u88c5\u8be5\u5e93\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u7b80\u5355\u7684\u51fd\u6570\u8c03\u7528\u5c06\u6c49\u5b57\u8f6c\u6362\u4e3a\u62fc\u97f3\u3002\u4f8b\u5982\uff0c\u4f7f\u7528<code>pypinyin.lazy_pinyin()<\/code>\u51fd\u6570\u53ef\u4ee5\u5b9e\u73b0\u8fd9\u4e00\u529f\u80fd\uff0c\u540c\u65f6\u4e5f\u652f\u6301\u5904\u7406\u591a\u97f3\u5b57\u3002<\/p>\n<p><strong>\u4f7f\u7528\u62fc\u97f3\u5e93\u65f6\uff0c\u5982\u4f55\u5904\u7406\u591a\u97f3\u5b57\u7684\u95ee\u9898\uff1f<\/strong><br \/>\u5728\u8f6c\u6362\u6c49\u5b57\u4e3a\u62fc\u97f3\u65f6\uff0c\u591a\u97f3\u5b57\u53ef\u80fd\u4f1a\u5bfc\u81f4\u62fc\u97f3\u7684\u6b67\u4e49\u3002\u4f7f\u7528<code>pypinyin<\/code>\u5e93\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e<code>style<\/code>\u53c2\u6570\u6765\u83b7\u53d6\u66f4\u8be6\u7ec6\u7684\u62fc\u97f3\u4fe1\u606f\uff0c\u4f8b\u5982\u4f7f\u7528<code>pypinyin.Style.TONE3<\/code>\u6765\u83b7\u53d6\u5e26\u58f0\u8c03\u7684\u62fc\u97f3\uff0c\u6216\u8005\u4f7f\u7528<code>pypinyin.Style.FIRST_LETTER<\/code>\u6765\u4ec5\u63d0\u53d6\u9996\u5b57\u6bcd\u3002<\/p>\n<p><strong>\u662f\u5426\u6709\u5176\u4ed6Python\u5e93\u53ef\u4ee5\u5b9e\u73b0\u6c49\u5b57\u5230\u62fc\u97f3\u7684\u8f6c\u6362\uff1f<\/strong><br \/>\u9664\u4e86<code>pypinyin<\/code>\u5916\uff0c\u60a8\u8fd8\u53ef\u4ee5\u8003\u8651\u4f7f\u7528<code>xpinyin<\/code>\u6216<code>hanziconv<\/code>\u7b49\u5e93\u3002\u8fd9\u4e9b\u5e93\u5404\u5177\u7279\u8272\uff0c\u6709\u7684\u63d0\u4f9b\u66f4\u4e30\u5bcc\u7684\u529f\u80fd\uff0c\u5982\u7b80\u7e41\u4f53\u8f6c\u6362\u7b49\u3002\u6839\u636e\u60a8\u7684\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u5e93\uff0c\u53ef\u4ee5\u66f4\u597d\u5730\u6ee1\u8db3\u9879\u76ee\u7684\u8981\u6c42\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u8981\u5c06\u6c49\u5b57\u8f6c\u6362\u4e3a\u62fc\u97f3\uff0c\u53ef\u4ee5\u4f7f\u7528Python\u4e2d\u7684\u4e00\u4e9b\u7b2c\u4e09\u65b9\u5e93\uff0c\u4f8b\u5982pypinyin\u3001xpinyin\u7b49\u3002\u4f7f\u7528pypi [&hellip;]","protected":false},"author":3,"featured_media":1169940,"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\/1169937"}],"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=1169937"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1169937\/revisions"}],"predecessor-version":[{"id":1169941,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1169937\/revisions\/1169941"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1169940"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1169937"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1169937"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1169937"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}