{"id":1171117,"date":"2025-01-15T16:31:15","date_gmt":"2025-01-15T08:31:15","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1171117.html"},"modified":"2025-01-15T16:31:18","modified_gmt":"2025-01-15T08:31:18","slug":"python%e5%a6%82%e4%bd%95%e5%9c%a8%e6%96%87%e6%9c%ac%e4%b8%8a%e5%ae%9e%e7%8e%b0","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1171117.html","title":{"rendered":"python\u5982\u4f55\u5728\u6587\u672c\u4e0a\u5b9e\u73b0"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/26073527\/4c311f8d-f5ef-4575-82d9-d8aea3e88b7a.webp\" alt=\"python\u5982\u4f55\u5728\u6587\u672c\u4e0a\u5b9e\u73b0\" \/><\/p>\n<p><p> <strong>Python\u53ef\u4ee5\u901a\u8fc7\u6b63\u5219\u8868\u8fbe\u5f0f\u3001\u5b57\u7b26\u4e32\u65b9\u6cd5\u3001\u6587\u672c\u5904\u7406\u5e93\u7b49\u591a\u79cd\u65b9\u5f0f\u5728\u6587\u672c\u4e0a\u5b9e\u73b0\u591a\u79cd\u64cd\u4f5c\u3002<\/strong> \u4f8b\u5982\uff0c\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u53ef\u4ee5\u8fdb\u884c\u590d\u6742\u7684\u6587\u672c\u5339\u914d\u548c\u66ff\u6362\u64cd\u4f5c\uff0c\u4f7f\u7528\u5b57\u7b26\u4e32\u65b9\u6cd5\u53ef\u4ee5\u8fdb\u884c\u7b80\u5355\u7684\u6587\u672c\u5904\u7406\uff0c\u4f7f\u7528\u6587\u672c\u5904\u7406\u5e93\uff08\u5982nltk\u3001spaCy\uff09\u53ef\u4ee5\u8fdb\u884c\u9ad8\u7ea7\u7684\u81ea\u7136\u8bed\u8a00\u5904\u7406\u3002<strong>\u5176\u4e2d\uff0c\u6b63\u5219\u8868\u8fbe\u5f0f\u662f\u4e00\u79cd\u975e\u5e38\u5f3a\u5927\u4e14\u7075\u6d3b\u7684\u6587\u672c\u5904\u7406\u5de5\u5177\u3002<\/strong><\/p>\n<\/p>\n<p><p>\u6b63\u5219\u8868\u8fbe\u5f0f\uff08Regular Expressions, Regex\uff09\u662f\u4e00\u79cd\u7528\u6765\u63cf\u8ff0\u5b57\u7b26\u4e32\u6a21\u5f0f\u7684\u5de5\u5177\uff0c\u80fd\u591f\u8fdb\u884c\u590d\u6742\u7684\u641c\u7d22\u3001\u66ff\u6362\u548c\u89e3\u6790\u64cd\u4f5c\u3002Python\u4e2d\u63d0\u4f9b\u4e86re\u6a21\u5757\u6765\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u3002\u901a\u8fc7\u6b63\u5219\u8868\u8fbe\u5f0f\uff0c\u53ef\u4ee5\u9ad8\u6548\u5730\u5904\u7406\u6587\u672c\u6570\u636e\uff0c\u4f8b\u5982\u63d0\u53d6\u7279\u5b9a\u6a21\u5f0f\u7684\u5b57\u7b26\u4e32\u3001\u66ff\u6362\u7279\u5b9a\u6a21\u5f0f\u7684\u5b57\u7b26\u4e32\u3001\u62c6\u5206\u5b57\u7b26\u4e32\u7b49\u7b49\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\uff0c\u901a\u8fc7\u6b63\u5219\u8868\u8fbe\u5f0f\u63d0\u53d6\u6587\u672c\u4e2d\u7684\u7535\u5b50\u90ae\u4ef6\u5730\u5740\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import re<\/p>\n<p>text = &quot;\u8bf7\u8054\u7cfbsupport@example.com\u6216\u8005sales@example.com\u83b7\u53d6\u66f4\u591a\u4fe1\u606f\u3002&quot;<\/p>\n<p>em<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>l_pattern = r&#39;\\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Z|a-z]{2,}\\b&#39;<\/p>\n<p>emails = re.findall(email_pattern, text)<\/p>\n<p>print(emails)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>re.findall<\/code>\u51fd\u6570\u6839\u636e\u7ed9\u5b9a\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u6a21\u5f0f\u5339\u914d\u6587\u672c\uff0c\u8fd4\u56de\u6240\u6709\u5339\u914d\u7684\u5b57\u7b26\u4e32\u3002<\/p>\n<\/p>\n<hr>\n<p><h3>\u4e00\u3001\u6b63\u5219\u8868\u8fbe\u5f0f<\/h3>\n<\/p>\n<p><p>\u6b63\u5219\u8868\u8fbe\u5f0f\u662f\u4e00\u79cd\u975e\u5e38\u7075\u6d3b\u548c\u5f3a\u5927\u7684\u6587\u672c\u5904\u7406\u5de5\u5177\u3002\u5b83\u5141\u8bb8\u4f60\u4f7f\u7528\u7279\u5b9a\u7684\u6a21\u5f0f\u8fdb\u884c\u6587\u672c\u5339\u914d\u3001\u66ff\u6362\u548c\u62c6\u5206\u64cd\u4f5c\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u5339\u914d\u64cd\u4f5c<\/h4>\n<\/p>\n<p><p>\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u5339\u914d\u64cd\u4f5c\u53ef\u4ee5\u7528\u4e8e\u67e5\u627e\u6587\u672c\u4e2d\u7b26\u5408\u7279\u5b9a\u6a21\u5f0f\u7684\u5b57\u7b26\u4e32\u3002\u6bd4\u5982\uff0c\u60f3\u8981\u5728\u4e00\u6bb5\u6587\u672c\u4e2d\u67e5\u627e\u6240\u6709\u7684\u7535\u8bdd\u53f7\u7801\uff0c\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u4ee3\u7801\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import re<\/p>\n<p>text = &quot;\u8054\u7cfb\u65b9\u5f0f\uff1a123-456-7890\uff0c\u5907\u7528\u7535\u8bdd\uff1a098-765-4321\u3002&quot;<\/p>\n<p>phone_pattern = r&#39;\\d{3}-\\d{3}-\\d{4}&#39;<\/p>\n<p>phones = re.findall(phone_pattern, text)<\/p>\n<p>print(phones)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6b63\u5219\u8868\u8fbe\u5f0f\u6a21\u5f0f<code>\\d{3}-\\d{3}-\\d{4}<\/code>\u8868\u793a\u5339\u914d\u4e09\u4e2a\u6570\u5b57\u3001\u4e00\u4e2a\u77ed\u6a2a\u7ebf\u3001\u4e09\u4e2a\u6570\u5b57\u3001\u4e00\u4e2a\u77ed\u6a2a\u7ebf\u3001\u56db\u4e2a\u6570\u5b57\u7684\u5b57\u7b26\u4e32\u3002<code>re.findall<\/code>\u51fd\u6570\u8fd4\u56de\u6240\u6709\u5339\u914d\u7684\u5b57\u7b26\u4e32\u5217\u8868\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u66ff\u6362\u64cd\u4f5c<\/h4>\n<\/p>\n<p><p>\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u66ff\u6362\u64cd\u4f5c\u53ef\u4ee5\u7528\u4e8e\u5c06\u6587\u672c\u4e2d\u7b26\u5408\u7279\u5b9a\u6a21\u5f0f\u7684\u5b57\u7b26\u4e32\u66ff\u6362\u4e3a\u6307\u5b9a\u7684\u5b57\u7b26\u4e32\u3002\u6bd4\u5982\uff0c\u60f3\u8981\u5c06\u6587\u672c\u4e2d\u7684\u7535\u8bdd\u53f7\u7801\u66ff\u6362\u4e3a\u201c[\u7535\u8bdd\u53f7\u7801]\u201d\uff0c\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u4ee3\u7801\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import re<\/p>\n<p>text = &quot;\u8054\u7cfb\u65b9\u5f0f\uff1a123-456-7890\uff0c\u5907\u7528\u7535\u8bdd\uff1a098-765-4321\u3002&quot;<\/p>\n<p>phone_pattern = r&#39;\\d{3}-\\d{3}-\\d{4}&#39;<\/p>\n<p>replaced_text = re.sub(phone_pattern, &#39;[\u7535\u8bdd\u53f7\u7801]&#39;, text)<\/p>\n<p>print(replaced_text)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>re.sub<\/code>\u51fd\u6570\u5c06\u6240\u6709\u7b26\u5408\u6a21\u5f0f\u7684\u5b57\u7b26\u4e32\u66ff\u6362\u4e3a\u6307\u5b9a\u7684\u5b57\u7b26\u4e32\u201c[\u7535\u8bdd\u53f7\u7801]\u201d\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u5b57\u7b26\u4e32\u65b9\u6cd5<\/h3>\n<\/p>\n<p><p>Python\u7684\u5b57\u7b26\u4e32\u65b9\u6cd5\u63d0\u4f9b\u4e86\u4e00\u4e9b\u57fa\u672c\u7684\u6587\u672c\u5904\u7406\u529f\u80fd\u3002\u867d\u7136\u6ca1\u6709\u6b63\u5219\u8868\u8fbe\u5f0f\u90a3\u4e48\u5f3a\u5927\uff0c\u4f46\u5728\u5904\u7406\u7b80\u5355\u6587\u672c\u64cd\u4f5c\u65f6\u975e\u5e38\u65b9\u4fbf\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u67e5\u627e\u548c\u66ff\u6362<\/h4>\n<\/p>\n<p><p>\u5b57\u7b26\u4e32\u65b9\u6cd5<code>find<\/code>\u548c<code>replace<\/code>\u53ef\u4ee5\u7528\u4e8e\u67e5\u627e\u548c\u66ff\u6362\u6587\u672c\u4e2d\u7684\u5b57\u7b26\u4e32\u3002\u4f8b\u5982\uff0c\u67e5\u627e\u6587\u672c\u4e2d\u67d0\u4e2a\u5355\u8bcd\u7684\u4f4d\u7f6e\uff0c\u66ff\u6362\u67d0\u4e2a\u5355\u8bcd\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">text = &quot;Python\u662f\u4e00\u79cd\u6d41\u884c\u7684\u7f16\u7a0b\u8bed\u8a00\u3002Python\u7b80\u5355\u6613\u5b66\u3002&quot;<\/p>\n<p>position = text.find(&quot;Python&quot;)<\/p>\n<p>print(f&quot;&#39;Python&#39;\u9996\u6b21\u51fa\u73b0\u7684\u4f4d\u7f6e\uff1a{position}&quot;)<\/p>\n<p>replaced_text = text.replace(&quot;Python&quot;, &quot;Java&quot;)<\/p>\n<p>print(replaced_text)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>find<\/code>\u65b9\u6cd5\u8fd4\u56de\u5b57\u7b26\u4e32\u4e2d\u9996\u6b21\u51fa\u73b0\u6307\u5b9a\u5b57\u7b26\u4e32\u7684\u4f4d\u7f6e\uff0c<code>replace<\/code>\u65b9\u6cd5\u5c06\u6240\u6709\u6307\u5b9a\u5b57\u7b26\u4e32\u66ff\u6362\u4e3a\u53e6\u4e00\u4e2a\u5b57\u7b26\u4e32\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u62c6\u5206\u548c\u8fde\u63a5<\/h4>\n<\/p>\n<p><p>\u5b57\u7b26\u4e32\u65b9\u6cd5<code>split<\/code>\u548c<code>join<\/code>\u53ef\u4ee5\u7528\u4e8e\u62c6\u5206\u548c\u8fde\u63a5\u5b57\u7b26\u4e32\u3002\u4f8b\u5982\uff0c\u5c06\u6587\u672c\u6309\u7a7a\u683c\u62c6\u5206\u4e3a\u5355\u8bcd\u5217\u8868\uff0c\u5c06\u5355\u8bcd\u5217\u8868\u8fde\u63a5\u4e3a\u6587\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">text = &quot;Python \u662f \u4e00\u79cd \u6d41\u884c \u7684 \u7f16\u7a0b \u8bed\u8a00\u3002&quot;<\/p>\n<p>words = text.split()<\/p>\n<p>print(words)<\/p>\n<p>joined_text = &quot; &quot;.join(words)<\/p>\n<p>print(joined_text)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>split<\/code>\u65b9\u6cd5\u6309\u7a7a\u683c\u62c6\u5206\u5b57\u7b26\u4e32\uff0c\u8fd4\u56de\u5355\u8bcd\u5217\u8868\uff0c<code>join<\/code>\u65b9\u6cd5\u5c06\u5355\u8bcd\u5217\u8868\u8fde\u63a5\u4e3a\u5b57\u7b26\u4e32\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u6587\u672c\u5904\u7406\u5e93<\/h3>\n<\/p>\n<p><p>Python\u6709\u8bb8\u591a\u5f3a\u5927\u7684\u6587\u672c\u5904\u7406\u5e93\uff0c\u5982nltk\u3001spaCy\u7b49\uff0c\u53ef\u4ee5\u8fdb\u884c\u9ad8\u7ea7\u7684\u81ea\u7136\u8bed\u8a00\u5904\u7406\u3002<\/p>\n<\/p>\n<p><h4>1\u3001NLTK<\/h4>\n<\/p>\n<p><p>NLTK\uff08Natural Language Toolkit\uff09\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u81ea\u7136\u8bed\u8a00\u5904\u7406\u5e93\uff0c\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u6587\u672c\u5904\u7406\u5de5\u5177\u548c\u8bed\u6599\u5e93\u3002\u4f8b\u5982\uff0c\u8fdb\u884c\u5206\u8bcd\u3001\u8bcd\u6027\u6807\u6ce8\u3001\u547d\u540d\u5b9e\u4f53\u8bc6\u522b\u7b49\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import nltk<\/p>\n<p>nltk.download(&#39;punkt&#39;)<\/p>\n<p>nltk.download(&#39;averaged_perceptron_tagger&#39;)<\/p>\n<p>text = &quot;Python is a popular programming language.&quot;<\/p>\n<p>words = nltk.word_tokenize(text)<\/p>\n<p>print(words)<\/p>\n<p>tagged_words = nltk.pos_tag(words)<\/p>\n<p>print(tagged_words)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>word_tokenize<\/code>\u65b9\u6cd5\u5c06\u6587\u672c\u5206\u8bcd\uff0c<code>pos_tag<\/code>\u65b9\u6cd5\u8fdb\u884c\u8bcd\u6027\u6807\u6ce8\u3002<\/p>\n<\/p>\n<p><h4>2\u3001spaCy<\/h4>\n<\/p>\n<p><p>spaCy\u662f\u53e6\u4e00\u4e2a\u5f3a\u5927\u7684\u81ea\u7136\u8bed\u8a00\u5904\u7406\u5e93\uff0c\u5177\u6709\u9ad8\u6548\u7684\u6027\u80fd\u548c\u6613\u7528\u7684API\u3002\u4f8b\u5982\uff0c\u8fdb\u884c\u5206\u8bcd\u3001\u8bcd\u6027\u6807\u6ce8\u3001\u547d\u540d\u5b9e\u4f53\u8bc6\u522b\u7b49\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import spacy<\/p>\n<p>nlp = spacy.load(&quot;en_core_web_sm&quot;)<\/p>\n<p>text = &quot;Python is a popular programming language.&quot;<\/p>\n<p>doc = nlp(text)<\/p>\n<p>for token in doc:<\/p>\n<p>    print(token.text, token.pos_, token.lemma_)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>nlp<\/code>\u65b9\u6cd5\u5c06\u6587\u672c\u5904\u7406\u4e3a\u6587\u6863\u5bf9\u8c61\uff0c<code>token<\/code>\u5bf9\u8c61\u5305\u542b\u5206\u8bcd\u3001\u8bcd\u6027\u6807\u6ce8\u3001\u8bcd\u5e72\u63d0\u53d6\u7b49\u4fe1\u606f\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u6587\u4ef6\u64cd\u4f5c\u4e0e\u6587\u672c\u5904\u7406<\/h3>\n<\/p>\n<p><p>\u6587\u672c\u5904\u7406\u4e0d\u4ec5\u4ec5\u5c40\u9650\u4e8e\u5b57\u7b26\u4e32\u548c\u6b63\u5219\u8868\u8fbe\u5f0f\uff0cPython\u8fd8\u53ef\u4ee5\u5904\u7406\u6587\u4ef6\u4e2d\u7684\u6587\u672c\u6570\u636e\u3002\u4f8b\u5982\uff0c\u8bfb\u53d6\u6587\u4ef6\u5185\u5bb9\u5e76\u8fdb\u884c\u5904\u7406\uff0c\u5199\u5165\u5904\u7406\u540e\u7684\u6587\u672c\u6570\u636e\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u8bfb\u53d6\u6587\u4ef6<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528Python\u7684\u5185\u7f6e\u51fd\u6570<code>open<\/code>\u53ef\u4ee5\u8bfb\u53d6\u6587\u672c\u6587\u4ef6\u7684\u5185\u5bb9\u3002\u4f8b\u5982\uff0c\u8bfb\u53d6\u6587\u4ef6\u5e76\u7edf\u8ba1\u5176\u4e2d\u7684\u5355\u8bcd\u9891\u7387\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from collections import Counter<\/p>\n<p>with open(&#39;example.txt&#39;, &#39;r&#39;) as file:<\/p>\n<p>    text = file.read()<\/p>\n<p>words = text.split()<\/p>\n<p>word_counts = Counter(words)<\/p>\n<p>print(word_counts)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>open<\/code>\u51fd\u6570\u6253\u5f00\u6587\u4ef6\uff0c<code>read<\/code>\u65b9\u6cd5\u8bfb\u53d6\u6587\u4ef6\u5185\u5bb9\uff0c<code>split<\/code>\u65b9\u6cd5\u5c06\u6587\u672c\u62c6\u5206\u4e3a\u5355\u8bcd\u5217\u8868\uff0c<code>Counter<\/code>\u7edf\u8ba1\u5355\u8bcd\u9891\u7387\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u5199\u5165\u6587\u4ef6<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528Python\u7684\u5185\u7f6e\u51fd\u6570<code>open<\/code>\u53ef\u4ee5\u5c06\u5904\u7406\u540e\u7684\u6587\u672c\u6570\u636e\u5199\u5165\u6587\u4ef6\u3002\u4f8b\u5982\uff0c\u5c06\u7edf\u8ba1\u7ed3\u679c\u5199\u5165\u6587\u4ef6\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">with open(&#39;word_counts.txt&#39;, &#39;w&#39;) as file:<\/p>\n<p>    for word, count in word_counts.items():<\/p>\n<p>        file.write(f&quot;{word}: {count}\\n&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>open<\/code>\u51fd\u6570\u4ee5\u5199\u6a21\u5f0f\u6253\u5f00\u6587\u4ef6\uff0c<code>write<\/code>\u65b9\u6cd5\u5c06\u7edf\u8ba1\u7ed3\u679c\u5199\u5165\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001\u6587\u672c\u9884\u5904\u7406<\/h3>\n<\/p>\n<p><p>\u5728\u8fdb\u884c\u6587\u672c\u5206\u6790\u4e4b\u524d\uff0c\u901a\u5e38\u9700\u8981\u5bf9\u6587\u672c\u6570\u636e\u8fdb\u884c\u9884\u5904\u7406\u3002\u5e38\u89c1\u7684\u6587\u672c\u9884\u5904\u7406\u6b65\u9aa4\u5305\u62ec\u53bb\u9664\u505c\u7528\u8bcd\u3001\u53bb\u9664\u6807\u70b9\u7b26\u53f7\u3001\u8f6c\u5316\u4e3a\u5c0f\u5199\u7b49\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u53bb\u9664\u505c\u7528\u8bcd<\/h4>\n<\/p>\n<p><p>\u505c\u7528\u8bcd\u662f\u6307\u5728\u6587\u672c\u5206\u6790\u4e2d\u4e0d\u592a\u91cd\u8981\u7684\u8bcd\uff0c\u5982\u201c\u7684\u201d\u3001\u201c\u662f\u201d\u3001\u201c\u5728\u201d\u7b49\u3002\u53ef\u4ee5\u4f7f\u7528nltk\u5e93\u53bb\u9664\u505c\u7528\u8bcd\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import nltk<\/p>\n<p>nltk.download(&#39;stopwords&#39;)<\/p>\n<p>from nltk.corpus import stopwords<\/p>\n<p>text = &quot;\u8fd9\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u6587\u672c\u5904\u7406\u793a\u4f8b\u3002&quot;<\/p>\n<p>words = nltk.word_tokenize(text)<\/p>\n<p>filtered_words = [word for word in words if word not in stopwords.words(&#39;chinese&#39;)]<\/p>\n<p>print(filtered_words)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>stopwords.words(&#39;chinese&#39;)<\/code>\u8fd4\u56de\u4e2d\u6587\u505c\u7528\u8bcd\u5217\u8868\uff0c\u5217\u8868\u63a8\u5bfc\u5f0f\u8fc7\u6ee4\u6389\u6587\u672c\u4e2d\u7684\u505c\u7528\u8bcd\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u53bb\u9664\u6807\u70b9\u7b26\u53f7<\/h4>\n<\/p>\n<p><p>\u6807\u70b9\u7b26\u53f7\u5728\u6587\u672c\u5206\u6790\u4e2d\u901a\u5e38\u6ca1\u6709\u592a\u5927\u610f\u4e49\uff0c\u53ef\u4ee5\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u53bb\u9664\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import re<\/p>\n<p>text = &quot;\u8fd9\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u6587\u672c\u5904\u7406\u793a\u4f8b\u3002&quot;<\/p>\n<p>cleaned_text = re.sub(r&#39;[^\\w\\s]&#39;, &#39;&#39;, text)<\/p>\n<p>print(cleaned_text)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6b63\u5219\u8868\u8fbe\u5f0f\u6a21\u5f0f<code>[^\\w\\s]<\/code>\u8868\u793a\u5339\u914d\u6240\u6709\u975e\u5b57\u6bcd\u6570\u5b57\u548c\u7a7a\u767d\u5b57\u7b26\u7684\u5b57\u7b26\uff0c<code>re.sub<\/code>\u51fd\u6570\u5c06\u5176\u66ff\u6362\u4e3a\u7a7a\u5b57\u7b26\u4e32\u3002<\/p>\n<\/p>\n<p><h3>\u516d\u3001\u6587\u672c\u7279\u5f81\u63d0\u53d6<\/h3>\n<\/p>\n<p><p>\u5728\u6587\u672c\u5206\u6790\u4e2d\uff0c\u5e38\u5e38\u9700\u8981\u5c06\u6587\u672c\u8f6c\u5316\u4e3a\u6570\u503c\u7279\u5f81\uff0c\u4fbf\u4e8e<a href=\"https:\/\/docs.pingcode.com\/ask\/59192.html\" target=\"_blank\">\u673a\u5668\u5b66\u4e60<\/a>\u6a21\u578b\u5904\u7406\u3002\u5e38\u89c1\u7684\u6587\u672c\u7279\u5f81\u63d0\u53d6\u65b9\u6cd5\u5305\u62ec\u8bcd\u888b\u6a21\u578b\uff08Bag of Words, BOW\uff09\u3001TF-IDF\u7b49\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u8bcd\u888b\u6a21\u578b<\/h4>\n<\/p>\n<p><p>\u8bcd\u888b\u6a21\u578b\u662f\u4e00\u79cd\u7b80\u5355\u4e14\u5e38\u7528\u7684\u6587\u672c\u7279\u5f81\u63d0\u53d6\u65b9\u6cd5\u3002\u53ef\u4ee5\u4f7f\u7528scikit-learn\u5e93\u5b9e\u73b0\u8bcd\u888b\u6a21\u578b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from sklearn.feature_extraction.text import CountVectorizer<\/p>\n<p>texts = [&quot;\u8fd9\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u6587\u672c\u5904\u7406\u793a\u4f8b\u3002&quot;, &quot;\u8fd9\u662f\u53e6\u4e00\u4e2a\u6587\u672c\u5904\u7406\u793a\u4f8b\u3002&quot;]<\/p>\n<p>vectorizer = CountVectorizer()<\/p>\n<p>X = vectorizer.fit_transform(texts)<\/p>\n<p>print(vectorizer.get_feature_names_out())<\/p>\n<p>print(X.toarray())<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>CountVectorizer<\/code>\u5c06\u6587\u672c\u8f6c\u5316\u4e3a\u8bcd\u888b\u6a21\u578b\u7684\u7279\u5f81\u77e9\u9635\uff0c<code>get_feature_names_out<\/code>\u65b9\u6cd5\u8fd4\u56de\u7279\u5f81\u540d\u79f0\uff0c<code>toarray<\/code>\u65b9\u6cd5\u8fd4\u56de\u7279\u5f81\u77e9\u9635\u7684\u7a00\u758f\u8868\u793a\u3002<\/p>\n<\/p>\n<p><h4>2\u3001TF-IDF<\/h4>\n<\/p>\n<p><p>TF-IDF\uff08Term Frequency-Inverse Document Frequency\uff09\u662f\u4e00\u79cd\u5e38\u7528\u7684\u6587\u672c\u7279\u5f81\u63d0\u53d6\u65b9\u6cd5\uff0c\u80fd\u591f\u8861\u91cf\u8bcd\u8bed\u5728\u6587\u672c\u4e2d\u7684\u91cd\u8981\u6027\u3002\u53ef\u4ee5\u4f7f\u7528scikit-learn\u5e93\u5b9e\u73b0TF-IDF\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from sklearn.feature_extraction.text import TfidfVectorizer<\/p>\n<p>texts = [&quot;\u8fd9\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u6587\u672c\u5904\u7406\u793a\u4f8b\u3002&quot;, &quot;\u8fd9\u662f\u53e6\u4e00\u4e2a\u6587\u672c\u5904\u7406\u793a\u4f8b\u3002&quot;]<\/p>\n<p>vectorizer = TfidfVectorizer()<\/p>\n<p>X = vectorizer.fit_transform(texts)<\/p>\n<p>print(vectorizer.get_feature_names_out())<\/p>\n<p>print(X.toarray())<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>TfidfVectorizer<\/code>\u5c06\u6587\u672c\u8f6c\u5316\u4e3aTF-IDF\u7684\u7279\u5f81\u77e9\u9635\uff0c<code>get_feature_names_out<\/code>\u65b9\u6cd5\u8fd4\u56de\u7279\u5f81\u540d\u79f0\uff0c<code>toarray<\/code>\u65b9\u6cd5\u8fd4\u56de\u7279\u5f81\u77e9\u9635\u7684\u7a00\u758f\u8868\u793a\u3002<\/p>\n<\/p>\n<p><h3>\u4e03\u3001\u6587\u672c\u5206\u7c7b<\/h3>\n<\/p>\n<p><p>\u6587\u672c\u5206\u7c7b\u662f\u81ea\u7136\u8bed\u8a00\u5904\u7406\u4e2d\u7684\u91cd\u8981\u4efb\u52a1\u4e4b\u4e00\uff0c\u53ef\u4ee5\u4f7f\u7528\u673a\u5668\u5b66\u4e60\u7b97\u6cd5\u5bf9\u6587\u672c\u8fdb\u884c\u5206\u7c7b\u3002\u5e38\u89c1\u7684\u6587\u672c\u5206\u7c7b\u65b9\u6cd5\u5305\u62ec\u6734\u7d20\u8d1d\u53f6\u65af\u3001\u652f\u6301\u5411\u91cf\u673a\u3001\u795e\u7ecf\u7f51\u7edc\u7b49\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u6734\u7d20\u8d1d\u53f6\u65af\u5206\u7c7b<\/h4>\n<\/p>\n<p><p>\u6734\u7d20\u8d1d\u53f6\u65af\u5206\u7c7b\u662f\u4e00\u79cd\u5e38\u7528\u7684\u6587\u672c\u5206\u7c7b\u7b97\u6cd5\uff0c\u9002\u7528\u4e8e\u5927\u89c4\u6a21\u6587\u672c\u5206\u7c7b\u4efb\u52a1\u3002\u53ef\u4ee5\u4f7f\u7528scikit-learn\u5e93\u5b9e\u73b0\u6734\u7d20\u8d1d\u53f6\u65af\u5206\u7c7b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from sklearn.feature_extraction.text import TfidfVectorizer<\/p>\n<p>from sklearn.naive_bayes import MultinomialNB<\/p>\n<p>from sklearn.model_selection import train_test_split<\/p>\n<p>from sklearn.metrics import accuracy_score<\/p>\n<p>texts = [&quot;\u8fd9\u662f\u4e00\u6761\u6b63\u9762\u8bc4\u8bba\u3002&quot;, &quot;\u8fd9\u662f\u4e00\u6761\u8d1f\u9762\u8bc4\u8bba\u3002&quot;, &quot;\u8fd9\u662f\u4e00\u6761\u4e2d\u6027\u8bc4\u8bba\u3002&quot;]<\/p>\n<p>labels = [&quot;\u6b63\u9762&quot;, &quot;\u8d1f\u9762&quot;, &quot;\u4e2d\u6027&quot;]<\/p>\n<p>vectorizer = TfidfVectorizer()<\/p>\n<p>X = vectorizer.fit_transform(texts)<\/p>\n<p>y = labels<\/p>\n<p>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)<\/p>\n<p>clf = MultinomialNB()<\/p>\n<p>clf.fit(X_train, y_train)<\/p>\n<p>y_pred = clf.predict(X_test)<\/p>\n<p>print(f&quot;\u5206\u7c7b\u51c6\u786e\u7387\uff1a{accuracy_score(y_test, y_pred)}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>TfidfVectorizer<\/code>\u5c06\u6587\u672c\u8f6c\u5316\u4e3aTF-IDF\u7279\u5f81\u77e9\u9635\uff0c<code>train_test_split<\/code>\u5c06\u6570\u636e\u96c6\u5212\u5206\u4e3a\u8bad\u7ec3\u96c6\u548c\u6d4b\u8bd5\u96c6\uff0c<code>MultinomialNB<\/code>\u8fdb\u884c\u6734\u7d20\u8d1d\u53f6\u65af\u5206\u7c7b\uff0c<code>accuracy_score<\/code>\u8ba1\u7b97\u5206\u7c7b\u51c6\u786e\u7387\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u652f\u6301\u5411\u91cf\u673a\u5206\u7c7b<\/h4>\n<\/p>\n<p><p>\u652f\u6301\u5411\u91cf\u673a\uff08SVM\uff09\u662f\u4e00\u79cd\u5f3a\u5927\u7684\u5206\u7c7b\u7b97\u6cd5\uff0c\u5e38\u7528\u4e8e\u6587\u672c\u5206\u7c7b\u4efb\u52a1\u3002\u53ef\u4ee5\u4f7f\u7528scikit-learn\u5e93\u5b9e\u73b0\u652f\u6301\u5411\u91cf\u673a\u5206\u7c7b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from sklearn.feature_extraction.text import TfidfVectorizer<\/p>\n<p>from sklearn.svm import SVC<\/p>\n<p>from sklearn.model_selection import train_test_split<\/p>\n<p>from sklearn.metrics import accuracy_score<\/p>\n<p>texts = [&quot;\u8fd9\u662f\u4e00\u6761\u6b63\u9762\u8bc4\u8bba\u3002&quot;, &quot;\u8fd9\u662f\u4e00\u6761\u8d1f\u9762\u8bc4\u8bba\u3002&quot;, &quot;\u8fd9\u662f\u4e00\u6761\u4e2d\u6027\u8bc4\u8bba\u3002&quot;]<\/p>\n<p>labels = [&quot;\u6b63\u9762&quot;, &quot;\u8d1f\u9762&quot;, &quot;\u4e2d\u6027&quot;]<\/p>\n<p>vectorizer = TfidfVectorizer()<\/p>\n<p>X = vectorizer.fit_transform(texts)<\/p>\n<p>y = labels<\/p>\n<p>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)<\/p>\n<p>clf = SVC(kernel=&#39;linear&#39;)<\/p>\n<p>clf.fit(X_train, y_train)<\/p>\n<p>y_pred = clf.predict(X_test)<\/p>\n<p>print(f&quot;\u5206\u7c7b\u51c6\u786e\u7387\uff1a{accuracy_score(y_test, y_pred)}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>TfidfVectorizer<\/code>\u5c06\u6587\u672c\u8f6c\u5316\u4e3aTF-IDF\u7279\u5f81\u77e9\u9635\uff0c<code>train_test_split<\/code>\u5c06\u6570\u636e\u96c6\u5212\u5206\u4e3a\u8bad\u7ec3\u96c6\u548c\u6d4b\u8bd5\u96c6\uff0c<code>SVC<\/code>\u8fdb\u884c\u652f\u6301\u5411\u91cf\u673a\u5206\u7c7b\uff0c<code>accuracy_score<\/code>\u8ba1\u7b97\u5206\u7c7b\u51c6\u786e\u7387\u3002<\/p>\n<\/p>\n<p><h3>\u516b\u3001\u60c5\u611f\u5206\u6790<\/h3>\n<\/p>\n<p><p>\u60c5\u611f\u5206\u6790\u662f\u81ea\u7136\u8bed\u8a00\u5904\u7406\u4e2d\u7684\u4e00\u79cd\u4efb\u52a1\uff0c\u7528\u4e8e\u5224\u65ad\u6587\u672c\u7684\u60c5\u611f\u503e\u5411\uff08\u5982\u6b63\u9762\u3001\u8d1f\u9762\u3001\u4e2d\u6027\uff09\u3002\u53ef\u4ee5\u4f7f\u7528TextBlob\u5e93\u8fdb\u884c\u60c5\u611f\u5206\u6790\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from textblob import TextBlob<\/p>\n<p>text = &quot;I love this product! It&#39;s amazing.&quot;<\/p>\n<p>blob = TextBlob(text)<\/p>\n<p>sentiment = blob.sentiment<\/p>\n<p>print(f&quot;\u60c5\u611f\u503e\u5411\uff1a{sentiment.polarity}&quot;)<\/p>\n<p>print(f&quot;\u60c5\u611f\u4e3b\u89c2\u6027\uff1a{sentiment.subjectivity}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>TextBlob<\/code>\u5bf9\u8c61\u5bf9\u6587\u672c\u8fdb\u884c\u60c5\u611f\u5206\u6790\uff0c<code>sentiment<\/code>\u5c5e\u6027\u8fd4\u56de\u60c5\u611f\u503e\u5411\uff08\u6781\u6027\uff09\u548c\u60c5\u611f\u4e3b\u89c2\u6027\u3002<\/p>\n<\/p>\n<p><h3>\u4e5d\u3001\u6587\u672c\u751f\u6210<\/h3>\n<\/p>\n<p><p>\u6587\u672c\u751f\u6210\u662f\u4e00\u79cd\u81ea\u7136\u8bed\u8a00\u5904\u7406\u4efb\u52a1\uff0c\u7528\u4e8e\u751f\u6210\u7c7b\u4f3c\u4e8e\u7ed9\u5b9a\u6587\u672c\u7684\u5185\u5bb9\u3002\u53ef\u4ee5\u4f7f\u7528GPT-3\u7b49\u8bed\u8a00\u6a21\u578b\u8fdb\u884c\u6587\u672c\u751f\u6210\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import openai<\/p>\n<p>openai.api_key = &#39;your-api-key&#39;<\/p>\n<p>response = openai.Completion.create(<\/p>\n<p>    engine=&quot;davinci&quot;,<\/p>\n<p>    prompt=&quot;Write a short story about a robot learning to love.&quot;,<\/p>\n<p>    max_tokens=100<\/p>\n<p>)<\/p>\n<p>print(response.choices[0].text.strip())<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>openai.Completion.create<\/code>\u65b9\u6cd5\u4f7f\u7528GPT-3\u751f\u6210\u6587\u672c\uff0c<code>response.choices[0].text<\/code>\u8fd4\u56de\u751f\u6210\u7684\u6587\u672c\u5185\u5bb9\u3002<\/p>\n<\/p>\n<p><h3>\u5341\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>Python\u5728\u6587\u672c\u5904\u7406\u65b9\u9762\u6709\u7740\u5e7f\u6cdb\u7684\u5e94\u7528\u548c\u5f3a\u5927\u7684\u529f\u80fd\u3002\u901a\u8fc7\u6b63\u5219\u8868\u8fbe\u5f0f\u3001\u5b57\u7b26\u4e32\u65b9\u6cd5\u3001\u6587\u672c\u5904\u7406\u5e93\u7b49\u5de5\u5177\uff0c\u53ef\u4ee5\u9ad8\u6548\u5730\u8fdb\u884c\u6587\u672c\u5339\u914d\u3001\u66ff\u6362\u3001\u62c6\u5206\u3001\u9884\u5904\u7406\u3001\u7279\u5f81\u63d0\u53d6\u3001\u5206\u7c7b\u3001\u60c5\u611f\u5206\u6790\u548c\u751f\u6210\u7b49\u64cd\u4f5c\u3002\u638c\u63e1\u8fd9\u4e9b\u6280\u672f\uff0c\u53ef\u4ee5\u5728\u81ea\u7136\u8bed\u8a00\u5904\u7406\u548c\u6587\u672c\u5206\u6790\u4e2d\u5927\u5c55\u8eab\u624b\u3002\u5e0c\u671b\u8fd9\u7bc7\u6587\u7ae0\u80fd\u4e3a\u60a8\u63d0\u4f9b\u6709\u4ef7\u503c\u7684\u53c2\u8003\uff0c\u5e2e\u52a9\u60a8\u66f4\u597d\u5730\u7406\u89e3\u548c\u5e94\u7528Python\u8fdb\u884c\u6587\u672c\u5904\u7406\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u4f7f\u7528Python\u5904\u7406\u6587\u672c\u6570\u636e\uff1f<\/strong><br \/>Python\u63d0\u4f9b\u4e86\u591a\u79cd\u5e93\u548c\u5de5\u5177\u7528\u4e8e\u6587\u672c\u5904\u7406\u3002\u5e38\u7528\u7684\u5e93\u5305\u62ec<code>re<\/code>\u7528\u4e8e\u6b63\u5219\u8868\u8fbe\u5f0f\u5339\u914d\u3001<code>nltk<\/code>\u7528\u4e8e\u81ea\u7136\u8bed\u8a00\u5904\u7406\u3001\u4ee5\u53ca<code>pandas<\/code>\u7528\u4e8e\u6570\u636e\u5206\u6790\u3002\u901a\u8fc7\u8fd9\u4e9b\u5e93\uff0c\u7528\u6237\u53ef\u4ee5\u8f7b\u677e\u8fdb\u884c\u6587\u672c\u6e05\u7406\u3001\u5206\u8bcd\u3001\u60c5\u611f\u5206\u6790\u7b49\u4efb\u52a1\u3002<\/p>\n<p><strong>Python\u4e2d\u6709\u54ea\u4e9b\u6587\u672c\u5904\u7406\u7684\u5e38\u7528\u65b9\u6cd5\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u5e38\u89c1\u7684\u6587\u672c\u5904\u7406\u65b9\u6cd5\u5305\u62ec\u5b57\u7b26\u4e32\u64cd\u4f5c\uff08\u5982\u5206\u5272\u3001\u66ff\u6362\u3001\u62fc\u63a5\uff09\u3001\u6b63\u5219\u8868\u8fbe\u5f0f\u5339\u914d\u3001\u6587\u672c\u6587\u4ef6\u8bfb\u5199\u3001\u4ee5\u53ca\u81ea\u7136\u8bed\u8a00\u5904\u7406\u6280\u672f\uff08\u5982\u8bcd\u9891\u7edf\u8ba1\u3001TF-IDF\u8ba1\u7b97\u7b49\uff09\u3002\u8fd9\u4e9b\u65b9\u6cd5\u53ef\u4ee5\u5e2e\u52a9\u7528\u6237\u9ad8\u6548\u5730\u5206\u6790\u548c\u5904\u7406\u6587\u672c\u6570\u636e\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728Python\u4e2d\u8bfb\u53d6\u548c\u5199\u5165\u6587\u672c\u6587\u4ef6\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u5185\u7f6e\u7684<code>open()<\/code>\u51fd\u6570\u8bfb\u53d6\u548c\u5199\u5165\u6587\u672c\u6587\u4ef6\u3002\u4f7f\u7528<code>&#39;r&#39;<\/code>\u6a21\u5f0f\u6253\u5f00\u6587\u4ef6\u53ef\u4ee5\u8bfb\u53d6\u5185\u5bb9\uff0c\u800c\u4f7f\u7528<code>&#39;w&#39;<\/code>\u6216<code>&#39;a&#39;<\/code>\u6a21\u5f0f\u53ef\u4ee5\u5199\u5165\u6216\u8ffd\u52a0\u5185\u5bb9\u3002\u901a\u8fc7<code>with<\/code>\u8bed\u53e5\uff0c\u53ef\u4ee5\u786e\u4fdd\u6587\u4ef6\u5728\u64cd\u4f5c\u5b8c\u6210\u540e\u81ea\u52a8\u5173\u95ed\uff0c\u4ece\u800c\u907f\u514d\u8d44\u6e90\u6cc4\u6f0f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Python\u53ef\u4ee5\u901a\u8fc7\u6b63\u5219\u8868\u8fbe\u5f0f\u3001\u5b57\u7b26\u4e32\u65b9\u6cd5\u3001\u6587\u672c\u5904\u7406\u5e93\u7b49\u591a\u79cd\u65b9\u5f0f\u5728\u6587\u672c\u4e0a\u5b9e\u73b0\u591a\u79cd\u64cd\u4f5c\u3002 \u4f8b\u5982\uff0c\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u53ef [&hellip;]","protected":false},"author":3,"featured_media":1171122,"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\/1171117"}],"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=1171117"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1171117\/revisions"}],"predecessor-version":[{"id":1171125,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1171117\/revisions\/1171125"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1171122"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1171117"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1171117"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1171117"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}