{"id":1186995,"date":"2025-01-15T19:59:44","date_gmt":"2025-01-15T11:59:44","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1186995.html"},"modified":"2025-01-15T19:59:47","modified_gmt":"2025-01-15T11:59:47","slug":"%e5%a6%82%e4%bd%95%e5%88%a9%e7%94%a8python%e7%88%ac%e8%99%ab%e6%90%9c%e4%b9%a6","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1186995.html","title":{"rendered":"\u5982\u4f55\u5229\u7528python\u722c\u866b\u641c\u4e66"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25135632\/4c9485b3-23c9-4a12-9611-a5aa6fdef318.webp\" alt=\"\u5982\u4f55\u5229\u7528python\u722c\u866b\u641c\u4e66\" \/><\/p>\n<p><p> \u5229\u7528Python\u722c\u866b\u6765\u641c\u4e66\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u51e0\u4e2a\u6b65\u9aa4\u6765\u5b9e\u73b0\uff1a<strong>\u9009\u62e9\u76ee\u6807\u7f51\u7ad9\u3001\u5206\u6790\u7f51\u9875\u7ed3\u6784\u3001\u7f16\u5199\u722c\u866b\u4ee3\u7801\u3001\u89e3\u6790\u548c\u63d0\u53d6\u6570\u636e\u3001\u6570\u636e\u5b58\u50a8\u548c\u5904\u7406<\/strong>\u3002\u5176\u4e2d\uff0c\u9009\u62e9\u76ee\u6807\u7f51\u7ad9\u662f\u975e\u5e38\u91cd\u8981\u7684\u4e00\u6b65\uff0c\u56e0\u4e3a\u4e0d\u540c\u7684\u7f51\u7ad9\u7ed3\u6784\u4e0d\u540c\uff0c\u9700\u8981\u901a\u8fc7\u5206\u6790\u7f51\u9875\u7ed3\u6784\u6765\u7f16\u5199\u76f8\u5e94\u7684\u722c\u866b\u4ee3\u7801\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u63cf\u8ff0\u5982\u4f55\u5229\u7528Python\u722c\u866b\u6765\u641c\u4e66\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u9009\u62e9\u76ee\u6807\u7f51\u7ad9<\/h3>\n<\/p>\n<p><p>\u9009\u62e9\u4e00\u4e2a\u76ee\u6807\u7f51\u7ad9\u662f\u722c\u866b\u7684\u7b2c\u4e00\u6b65\u3002\u5e38\u89c1\u7684\u4e66\u7c4d\u7f51\u7ad9\u5305\u62ec\u8c46\u74e3\u8bfb\u4e66\u3001\u5f53\u5f53\u7f51\u3001\u4eac\u4e1c\u56fe\u4e66\u7b49\u3002\u8fd9\u4e9b\u7f51\u7ad9\u63d0\u4f9b\u4e86\u5927\u91cf\u7684\u4e66\u7c4d\u4fe1\u606f\uff0c\u53ef\u4ee5\u901a\u8fc7\u722c\u866b\u83b7\u53d6\u5230\u9700\u8981\u7684\u6570\u636e\u3002\u5728\u9009\u62e9\u76ee\u6807\u7f51\u7ad9\u65f6\uff0c\u9700\u8981\u786e\u4fdd\u7f51\u7ad9\u7684\u5185\u5bb9\u662f\u516c\u5f00\u7684\uff0c\u5e76\u4e14\u6ca1\u6709\u8fdd\u53cd\u7f51\u7ad9\u7684\u4f7f\u7528\u6761\u6b3e\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u5206\u6790\u7f51\u9875\u7ed3\u6784<\/h3>\n<\/p>\n<p><p>\u5728\u9009\u62e9\u597d\u76ee\u6807\u7f51\u7ad9\u540e\uff0c\u9700\u8981\u5bf9\u7f51\u9875\u8fdb\u884c\u5206\u6790\uff0c\u627e\u51fa\u9700\u8981\u7684\u6570\u636e\u6240\u5728\u7684\u4f4d\u7f6e\u3002\u53ef\u4ee5\u4f7f\u7528\u6d4f\u89c8\u5668\u7684\u5f00\u53d1\u8005\u5de5\u5177\uff08\u5982Chrome\u7684\u5f00\u53d1\u8005\u5de5\u5177\uff09\u6765\u67e5\u770b\u7f51\u9875\u7684\u7ed3\u6784\uff0c\u627e\u5230\u9700\u8981\u722c\u53d6\u7684\u6570\u636e\u6240\u5728\u7684HTML\u6807\u7b7e\u548c\u5c5e\u6027\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u7f16\u5199\u722c\u866b\u4ee3\u7801<\/h3>\n<\/p>\n<p><p>\u7f16\u5199\u722c\u866b\u4ee3\u7801\u662f\u6838\u5fc3\u6b65\u9aa4\u3002\u53ef\u4ee5\u4f7f\u7528Python\u7684requests\u5e93\u6765\u53d1\u9001HTTP\u8bf7\u6c42\uff0c\u83b7\u53d6\u7f51\u9875\u5185\u5bb9\uff1b\u4f7f\u7528BeautifulSoup\u5e93\u6765\u89e3\u6790HTML\u6587\u6863\uff0c\u63d0\u53d6\u9700\u8981\u7684\u6570\u636e\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\u4ee3\u7801\uff0c\u5c55\u793a\u4e86\u5982\u4f55\u722c\u53d6\u8c46\u74e3\u8bfb\u4e66\u4e0a\u7684\u4e66\u7c4d\u4fe1\u606f\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import requests<\/p>\n<p>from bs4 import BeautifulSoup<\/p>\n<h2><strong>\u53d1\u9001HTTP\u8bf7\u6c42\uff0c\u83b7\u53d6\u7f51\u9875\u5185\u5bb9<\/strong><\/h2>\n<p>url = &#39;https:\/\/book.douban.com\/tag\/\u5c0f\u8bf4&#39;<\/p>\n<p>response = requests.get(url)<\/p>\n<p>html_content = response.text<\/p>\n<h2><strong>\u89e3\u6790HTML\u6587\u6863<\/strong><\/h2>\n<p>soup = BeautifulSoup(html_content, &#39;html.parser&#39;)<\/p>\n<h2><strong>\u63d0\u53d6\u4e66\u7c4d\u4fe1\u606f<\/strong><\/h2>\n<p>books = soup.find_all(&#39;div&#39;, class_=&#39;info&#39;)<\/p>\n<p>for book in books:<\/p>\n<p>    title = book.find(&#39;a&#39;).get_text().strip()<\/p>\n<p>    author = book.find(&#39;div&#39;, class_=&#39;pub&#39;).get_text().strip()<\/p>\n<p>    print(f&#39;Title: {title}, Author: {author}&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u56db\u3001\u89e3\u6790\u548c\u63d0\u53d6\u6570\u636e<\/h3>\n<\/p>\n<p><p>\u5728\u83b7\u53d6\u5230\u7f51\u9875\u5185\u5bb9\u540e\uff0c\u9700\u8981\u4f7f\u7528BeautifulSoup\u5e93\u6765\u89e3\u6790HTML\u6587\u6863\uff0c\u63d0\u53d6\u9700\u8981\u7684\u6570\u636e\u3002\u53ef\u4ee5\u901a\u8fc7find_all\u65b9\u6cd5\u627e\u5230\u6240\u6709\u7b26\u5408\u6761\u4ef6\u7684\u6807\u7b7e\uff0c\u904d\u5386\u8fd9\u4e9b\u6807\u7b7e\uff0c\u63d0\u53d6\u5176\u4e2d\u7684\u6587\u672c\u5185\u5bb9\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001\u6570\u636e\u5b58\u50a8\u548c\u5904\u7406<\/h3>\n<\/p>\n<p><p>\u6700\u540e\u4e00\u6b65\u662f\u5c06\u63d0\u53d6\u5230\u7684\u6570\u636e\u8fdb\u884c\u5b58\u50a8\u548c\u5904\u7406\u3002\u53ef\u4ee5\u5c06\u6570\u636e\u5b58\u50a8\u5230CSV\u6587\u4ef6\u3001\u6570\u636e\u5e93\u7b49\u683c\u5f0f\u4e2d\uff0c\u65b9\u4fbf\u540e\u7eed\u7684\u6570\u636e\u5206\u6790\u548c\u5904\u7406\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\u4ee3\u7801\uff0c\u5c55\u793a\u4e86\u5982\u4f55\u5c06\u63d0\u53d6\u5230\u7684\u4e66\u7c4d\u4fe1\u606f\u5b58\u50a8\u5230CSV\u6587\u4ef6\u4e2d\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import csv<\/p>\n<h2><strong>\u6253\u5f00CSV\u6587\u4ef6\uff0c\u51c6\u5907\u5199\u5165\u6570\u636e<\/strong><\/h2>\n<p>with open(&#39;books.csv&#39;, &#39;w&#39;, newline=&#39;&#39;, encoding=&#39;utf-8&#39;) as csvfile:<\/p>\n<p>    fieldnames = [&#39;Title&#39;, &#39;Author&#39;]<\/p>\n<p>    writer = csv.DictWriter(csvfile, fieldnames=fieldnames)<\/p>\n<p>    writer.writeheader()<\/p>\n<p>    for book in books:<\/p>\n<p>        title = book.find(&#39;a&#39;).get_text().strip()<\/p>\n<p>        author = book.find(&#39;div&#39;, class_=&#39;pub&#39;).get_text().strip()<\/p>\n<p>        writer.writerow({&#39;Title&#39;: title, &#39;Author&#39;: author})<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e00\u3001\u9009\u62e9\u76ee\u6807\u7f51\u7ad9<\/h3>\n<\/p>\n<p><p>\u9009\u62e9\u76ee\u6807\u7f51\u7ad9\u662f\u722c\u866b\u7684\u7b2c\u4e00\u6b65\u3002\u9700\u8981\u9009\u62e9\u4e00\u4e2a\u63d0\u4f9b\u4e66\u7c4d\u4fe1\u606f\u7684\u7f51\u7ad9\uff0c\u6bd4\u5982\u8c46\u74e3\u8bfb\u4e66\u3001\u5f53\u5f53\u7f51\u3001\u4eac\u4e1c\u56fe\u4e66\u7b49\u3002\u8fd9\u4e9b\u7f51\u7ad9\u63d0\u4f9b\u4e86\u5927\u91cf\u7684\u4e66\u7c4d\u4fe1\u606f\uff0c\u53ef\u4ee5\u901a\u8fc7\u722c\u866b\u83b7\u53d6\u5230\u9700\u8981\u7684\u6570\u636e\u3002<\/p>\n<\/p>\n<p><p>\u5728\u9009\u62e9\u76ee\u6807\u7f51\u7ad9\u65f6\uff0c\u9700\u8981\u6ce8\u610f\u4ee5\u4e0b\u51e0\u70b9\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u7f51\u7ad9\u5185\u5bb9\u662f\u5426\u516c\u5f00\uff1a\u786e\u4fdd\u9009\u62e9\u7684\u7f51\u7ad9\u5185\u5bb9\u662f\u516c\u5f00\u7684\uff0c\u6ca1\u6709\u8fdd\u53cd\u7f51\u7ad9\u7684\u4f7f\u7528\u6761\u6b3e\u3002<\/li>\n<li>\u7f51\u7ad9\u7ed3\u6784\u662f\u5426\u6e05\u6670\uff1a\u9009\u62e9\u7ed3\u6784\u6e05\u6670\u3001\u6613\u4e8e\u89e3\u6790\u7684\u7f51\u7ad9\uff0c\u53ef\u4ee5\u51cf\u5c11\u722c\u866b\u7f16\u5199\u7684\u96be\u5ea6\u3002<\/li>\n<li>\u6570\u636e\u662f\u5426\u4e30\u5bcc\uff1a\u9009\u62e9\u6570\u636e\u4e30\u5bcc\u7684\u7f51\u7ad9\uff0c\u53ef\u4ee5\u83b7\u53d6\u5230\u66f4\u591a\u6709\u4ef7\u503c\u7684\u4fe1\u606f\u3002<\/li>\n<\/ol>\n<p><h3>\u4e8c\u3001\u5206\u6790\u7f51\u9875\u7ed3\u6784<\/h3>\n<\/p>\n<p><p>\u5728\u9009\u62e9\u597d\u76ee\u6807\u7f51\u7ad9\u540e\uff0c\u9700\u8981\u5bf9\u7f51\u9875\u8fdb\u884c\u5206\u6790\uff0c\u627e\u51fa\u9700\u8981\u7684\u6570\u636e\u6240\u5728\u7684\u4f4d\u7f6e\u3002\u53ef\u4ee5\u4f7f\u7528\u6d4f\u89c8\u5668\u7684\u5f00\u53d1\u8005\u5de5\u5177\uff08\u5982Chrome\u7684\u5f00\u53d1\u8005\u5de5\u5177\uff09\u6765\u67e5\u770b\u7f51\u9875\u7684\u7ed3\u6784\uff0c\u627e\u5230\u9700\u8981\u722c\u53d6\u7684\u6570\u636e\u6240\u5728\u7684HTML\u6807\u7b7e\u548c\u5c5e\u6027\u3002<\/p>\n<\/p>\n<p><h4>\u4f7f\u7528\u6d4f\u89c8\u5668\u7684\u5f00\u53d1\u8005\u5de5\u5177<\/h4>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u76ee\u6807\u7f51\u7ad9\uff0c\u53f3\u952e\u70b9\u51fb\u9875\u9762\uff0c\u9009\u62e9\u201c\u68c0\u67e5\u201d\u6216\u6309F12\u952e\u6253\u5f00\u5f00\u53d1\u8005\u5de5\u5177\u3002<\/li>\n<li>\u5728\u5f00\u53d1\u8005\u5de5\u5177\u4e2d\uff0c\u9009\u62e9\u201cElements\u201d\u6807\u7b7e\uff0c\u67e5\u770b\u7f51\u9875\u7684HTML\u7ed3\u6784\u3002<\/li>\n<li>\u4f7f\u7528\u9f20\u6807\u60ac\u505c\u5728\u7f51\u9875\u5143\u7d20\u4e0a\uff0c\u53ef\u4ee5\u9ad8\u4eae\u663e\u793a\u5bf9\u5e94\u7684HTML\u6807\u7b7e\uff0c\u627e\u5230\u9700\u8981\u722c\u53d6\u7684\u6570\u636e\u6240\u5728\u7684\u6807\u7b7e\u548c\u5c5e\u6027\u3002<\/li>\n<\/ol>\n<p><h4>\u5206\u6790HTML\u7ed3\u6784<\/h4>\n<\/p>\n<p><p>\u5728\u5f00\u53d1\u8005\u5de5\u5177\u4e2d\uff0c\u627e\u5230\u9700\u8981\u722c\u53d6\u7684\u6570\u636e\u6240\u5728\u7684HTML\u6807\u7b7e\u3002\u6bd4\u5982\uff0c\u5728\u8c46\u74e3\u8bfb\u4e66\u7684\u4e66\u7c4d\u5217\u8868\u9875\u9762\uff0c\u6bcf\u672c\u4e66\u7684\u4fe1\u606f\u901a\u5e38\u5305\u542b\u5728\u4e00\u4e2adiv\u6807\u7b7e\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7class\u5c5e\u6027\u6765\u5b9a\u4f4d\u8fd9\u4e2a\u6807\u7b7e\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u7f16\u5199\u722c\u866b\u4ee3\u7801<\/h3>\n<\/p>\n<p><p>\u7f16\u5199\u722c\u866b\u4ee3\u7801\u662f\u6838\u5fc3\u6b65\u9aa4\u3002\u53ef\u4ee5\u4f7f\u7528Python\u7684requests\u5e93\u6765\u53d1\u9001HTTP\u8bf7\u6c42\uff0c\u83b7\u53d6\u7f51\u9875\u5185\u5bb9\uff1b\u4f7f\u7528BeautifulSoup\u5e93\u6765\u89e3\u6790HTML\u6587\u6863\uff0c\u63d0\u53d6\u9700\u8981\u7684\u6570\u636e\u3002<\/p>\n<\/p>\n<p><h4>\u5b89\u88c5\u6240\u9700\u7684\u5e93<\/h4>\n<\/p>\n<p><p>\u5728\u7f16\u5199\u722c\u866b\u4ee3\u7801\u524d\uff0c\u9700\u8981\u5b89\u88c5requests\u548cBeautifulSoup\u5e93\uff0c\u53ef\u4ee5\u4f7f\u7528pip\u8fdb\u884c\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install requests<\/p>\n<p>pip install beautifulsoup4<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u7f16\u5199\u722c\u866b\u4ee3\u7801<\/h4>\n<\/p>\n<p><p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\u4ee3\u7801\uff0c\u5c55\u793a\u4e86\u5982\u4f55\u722c\u53d6\u8c46\u74e3\u8bfb\u4e66\u4e0a\u7684\u4e66\u7c4d\u4fe1\u606f\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import requests<\/p>\n<p>from bs4 import BeautifulSoup<\/p>\n<h2><strong>\u53d1\u9001HTTP\u8bf7\u6c42\uff0c\u83b7\u53d6\u7f51\u9875\u5185\u5bb9<\/strong><\/h2>\n<p>url = &#39;https:\/\/book.douban.com\/tag\/\u5c0f\u8bf4&#39;<\/p>\n<p>response = requests.get(url)<\/p>\n<p>html_content = response.text<\/p>\n<h2><strong>\u89e3\u6790HTML\u6587\u6863<\/strong><\/h2>\n<p>soup = BeautifulSoup(html_content, &#39;html.parser&#39;)<\/p>\n<h2><strong>\u63d0\u53d6\u4e66\u7c4d\u4fe1\u606f<\/strong><\/h2>\n<p>books = soup.find_all(&#39;div&#39;, class_=&#39;info&#39;)<\/p>\n<p>for book in books:<\/p>\n<p>    title = book.find(&#39;a&#39;).get_text().strip()<\/p>\n<p>    author = book.find(&#39;div&#39;, class_=&#39;pub&#39;).get_text().strip()<\/p>\n<p>    print(f&#39;Title: {title}, Author: {author}&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u56db\u3001\u89e3\u6790\u548c\u63d0\u53d6\u6570\u636e<\/h3>\n<\/p>\n<p><p>\u5728\u83b7\u53d6\u5230\u7f51\u9875\u5185\u5bb9\u540e\uff0c\u9700\u8981\u4f7f\u7528BeautifulSoup\u5e93\u6765\u89e3\u6790HTML\u6587\u6863\uff0c\u63d0\u53d6\u9700\u8981\u7684\u6570\u636e\u3002\u53ef\u4ee5\u901a\u8fc7find_all\u65b9\u6cd5\u627e\u5230\u6240\u6709\u7b26\u5408\u6761\u4ef6\u7684\u6807\u7b7e\uff0c\u904d\u5386\u8fd9\u4e9b\u6807\u7b7e\uff0c\u63d0\u53d6\u5176\u4e2d\u7684\u6587\u672c\u5185\u5bb9\u3002<\/p>\n<\/p>\n<p><h4>\u4f7f\u7528BeautifulSoup\u89e3\u6790HTML<\/h4>\n<\/p>\n<p><p>BeautifulSoup\u662f\u4e00\u4e2a\u529f\u80fd\u5f3a\u5927\u7684HTML\u89e3\u6790\u5e93\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u89e3\u6790\u548c\u64cd\u4f5cHTML\u6587\u6863\u3002\u5728\u89e3\u6790HTML\u6587\u6863\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5\uff1a<\/p>\n<\/p>\n<ol>\n<li><code>soup.find_all(tag, attrs)<\/code>: \u67e5\u627e\u6240\u6709\u7b26\u5408\u6761\u4ef6\u7684\u6807\u7b7e\u3002<\/li>\n<li><code>tag.get_text()<\/code>: \u83b7\u53d6\u6807\u7b7e\u4e2d\u7684\u6587\u672c\u5185\u5bb9\u3002<\/li>\n<li><code>tag[&#39;attribute&#39;]<\/code>: \u83b7\u53d6\u6807\u7b7e\u7684\u5c5e\u6027\u503c\u3002<\/li>\n<\/ol>\n<p><p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\u4ee3\u7801\uff0c\u5c55\u793a\u4e86\u5982\u4f55\u4f7f\u7528BeautifulSoup\u89e3\u6790HTML\u6587\u6863\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import requests<\/p>\n<p>from bs4 import BeautifulSoup<\/p>\n<h2><strong>\u53d1\u9001HTTP\u8bf7\u6c42\uff0c\u83b7\u53d6\u7f51\u9875\u5185\u5bb9<\/strong><\/h2>\n<p>url = &#39;https:\/\/book.douban.com\/tag\/\u5c0f\u8bf4&#39;<\/p>\n<p>response = requests.get(url)<\/p>\n<p>html_content = response.text<\/p>\n<h2><strong>\u89e3\u6790HTML\u6587\u6863<\/strong><\/h2>\n<p>soup = BeautifulSoup(html_content, &#39;html.parser&#39;)<\/p>\n<h2><strong>\u63d0\u53d6\u4e66\u7c4d\u4fe1\u606f<\/strong><\/h2>\n<p>books = soup.find_all(&#39;div&#39;, class_=&#39;info&#39;)<\/p>\n<p>for book in books:<\/p>\n<p>    title = book.find(&#39;a&#39;).get_text().strip()<\/p>\n<p>    author = book.find(&#39;div&#39;, class_=&#39;pub&#39;).get_text().strip()<\/p>\n<p>    print(f&#39;Title: {title}, Author: {author}&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e94\u3001\u6570\u636e\u5b58\u50a8\u548c\u5904\u7406<\/h3>\n<\/p>\n<p><p>\u6700\u540e\u4e00\u6b65\u662f\u5c06\u63d0\u53d6\u5230\u7684\u6570\u636e\u8fdb\u884c\u5b58\u50a8\u548c\u5904\u7406\u3002\u53ef\u4ee5\u5c06\u6570\u636e\u5b58\u50a8\u5230CSV\u6587\u4ef6\u3001\u6570\u636e\u5e93\u7b49\u683c\u5f0f\u4e2d\uff0c\u65b9\u4fbf\u540e\u7eed\u7684\u6570\u636e\u5206\u6790\u548c\u5904\u7406\u3002<\/p>\n<\/p>\n<p><h4>\u5c06\u6570\u636e\u5b58\u50a8\u5230CSV\u6587\u4ef6<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u4f7f\u7528Python\u5185\u7f6e\u7684csv\u5e93\u5c06\u6570\u636e\u5b58\u50a8\u5230CSV\u6587\u4ef6\u4e2d\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\u4ee3\u7801\uff0c\u5c55\u793a\u4e86\u5982\u4f55\u5c06\u63d0\u53d6\u5230\u7684\u4e66\u7c4d\u4fe1\u606f\u5b58\u50a8\u5230CSV\u6587\u4ef6\u4e2d\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import csv<\/p>\n<h2><strong>\u6253\u5f00CSV\u6587\u4ef6\uff0c\u51c6\u5907\u5199\u5165\u6570\u636e<\/strong><\/h2>\n<p>with open(&#39;books.csv&#39;, &#39;w&#39;, newline=&#39;&#39;, encoding=&#39;utf-8&#39;) as csvfile:<\/p>\n<p>    fieldnames = [&#39;Title&#39;, &#39;Author&#39;]<\/p>\n<p>    writer = csv.DictWriter(csvfile, fieldnames=fieldnames)<\/p>\n<p>    writer.writeheader()<\/p>\n<p>    for book in books:<\/p>\n<p>        title = book.find(&#39;a&#39;).get_text().strip()<\/p>\n<p>        author = book.find(&#39;div&#39;, class_=&#39;pub&#39;).get_text().strip()<\/p>\n<p>        writer.writerow({&#39;Title&#39;: title, &#39;Author&#39;: author})<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u5c06\u6570\u636e\u5b58\u50a8\u5230\u6570\u636e\u5e93<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u4f7f\u7528Python\u7684\u6570\u636e\u5e93\u8fde\u63a5\u5e93\uff08\u5982sqlite3\u3001pymysql\u7b49\uff09\u5c06\u6570\u636e\u5b58\u50a8\u5230\u6570\u636e\u5e93\u4e2d\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\u4ee3\u7801\uff0c\u5c55\u793a\u4e86\u5982\u4f55\u5c06\u63d0\u53d6\u5230\u7684\u4e66\u7c4d\u4fe1\u606f\u5b58\u50a8\u5230SQLite\u6570\u636e\u5e93\u4e2d\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import sqlite3<\/p>\n<h2><strong>\u8fde\u63a5SQLite\u6570\u636e\u5e93<\/strong><\/h2>\n<p>conn = sqlite3.connect(&#39;books.db&#39;)<\/p>\n<p>c = conn.cursor()<\/p>\n<h2><strong>\u521b\u5efa\u8868<\/strong><\/h2>\n<p>c.execute(&#39;&#39;&#39;CREATE TABLE IF NOT EXISTS books<\/p>\n<p>             (title TEXT, author TEXT)&#39;&#39;&#39;)<\/p>\n<h2><strong>\u63d2\u5165\u6570\u636e<\/strong><\/h2>\n<p>for book in books:<\/p>\n<p>    title = book.find(&#39;a&#39;).get_text().strip()<\/p>\n<p>    author = book.find(&#39;div&#39;, class_=&#39;pub&#39;).get_text().strip()<\/p>\n<p>    c.execute(&quot;INSERT INTO books (title, author) VALUES (?, ?)&quot;, (title, author))<\/p>\n<h2><strong>\u63d0\u4ea4\u4e8b\u52a1<\/strong><\/h2>\n<p>conn.commit()<\/p>\n<h2><strong>\u5173\u95ed\u8fde\u63a5<\/strong><\/h2>\n<p>conn.close()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u516d\u3001\u5904\u7406\u53cd\u722c\u866b\u673a\u5236<\/h3>\n<\/p>\n<p><p>\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u5f88\u591a\u7f51\u7ad9\u4f1a\u6709\u53cd\u722c\u866b\u673a\u5236\uff0c\u9650\u5236\u722c\u866b\u7684\u8bbf\u95ee\u9891\u7387\u3002\u4e3a\u4e86\u7ed5\u8fc7\u53cd\u722c\u866b\u673a\u5236\uff0c\u53ef\u4ee5\u91c7\u53d6\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5\uff1a<\/p>\n<\/p>\n<p><h4>\u8bbe\u7f6e\u8bf7\u6c42\u5934\u90e8<\/h4>\n<\/p>\n<p><p>\u901a\u8fc7\u8bbe\u7f6eHTTP\u8bf7\u6c42\u5934\u90e8\uff0c\u53ef\u4ee5\u4f2a\u88c5\u6210\u6d4f\u89c8\u5668\u8bbf\u95ee\uff0c\u907f\u514d\u88ab\u8bc6\u522b\u4e3a\u722c\u866b\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\u4ee3\u7801\uff0c\u5c55\u793a\u4e86\u5982\u4f55\u8bbe\u7f6e\u8bf7\u6c42\u5934\u90e8\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import requests<\/p>\n<p>headers = {<\/p>\n<p>    &#39;User-Agent&#39;: &#39;Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/91.0.4472.124 Safari\/537.36&#39;<\/p>\n<p>}<\/p>\n<p>url = &#39;https:\/\/book.douban.com\/tag\/\u5c0f\u8bf4&#39;<\/p>\n<p>response = requests.get(url, headers=headers)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u8bbe\u7f6e\u5ef6\u65f6<\/h4>\n<\/p>\n<p><p>\u901a\u8fc7\u8bbe\u7f6e\u8bbf\u95ee\u5ef6\u65f6\uff0c\u53ef\u4ee5\u907f\u514d\u9891\u7e41\u8bbf\u95ee\u5bfc\u81f4\u88ab\u5c01\u7981\u3002\u53ef\u4ee5\u4f7f\u7528time\u5e93\u6765\u8bbe\u7f6e\u5ef6\u65f6\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import time<\/p>\n<h2><strong>\u8bbe\u7f6e\u5ef6\u65f6<\/strong><\/h2>\n<p>time.sleep(2)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u4f7f\u7528\u4ee3\u7406<\/h4>\n<\/p>\n<p><p>\u901a\u8fc7\u4f7f\u7528\u4ee3\u7406\uff0c\u53ef\u4ee5\u9690\u85cf\u771f\u5b9e\u7684IP\u5730\u5740\uff0c\u907f\u514d\u88ab\u5c01\u7981\u3002\u53ef\u4ee5\u4f7f\u7528requests\u5e93\u7684proxies\u53c2\u6570\u6765\u8bbe\u7f6e\u4ee3\u7406\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import requests<\/p>\n<p>proxies = {<\/p>\n<p>    &#39;http&#39;: &#39;http:\/\/10.10.10.10:8000&#39;,<\/p>\n<p>    &#39;https&#39;: &#39;http:\/\/10.10.10.10:8000&#39;,<\/p>\n<p>}<\/p>\n<p>url = &#39;https:\/\/book.douban.com\/tag\/\u5c0f\u8bf4&#39;<\/p>\n<p>response = requests.get(url, proxies=proxies)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e03\u3001\u5904\u7406\u52a8\u6001\u7f51\u9875<\/h3>\n<\/p>\n<p><p>\u6709\u4e9b\u7f51\u7ad9\u4f7f\u7528\u4e86JavaScript\u52a0\u8f7d\u6570\u636e\uff0c\u76f4\u63a5\u83b7\u53d6HTML\u5185\u5bb9\u53ef\u80fd\u65e0\u6cd5\u83b7\u53d6\u5230\u9700\u8981\u7684\u6570\u636e\u3002\u8fd9\u65f6\u53ef\u4ee5\u4f7f\u7528Selenium\u5e93\uff0c\u6a21\u62df\u6d4f\u89c8\u5668\u64cd\u4f5c\uff0c\u83b7\u53d6\u52a8\u6001\u52a0\u8f7d\u7684\u6570\u636e\u3002<\/p>\n<\/p>\n<p><h4>\u5b89\u88c5Selenium\u548c\u6d4f\u89c8\u5668\u9a71\u52a8<\/h4>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u9700\u8981\u5b89\u88c5Selenium\u5e93\u548c\u6d4f\u89c8\u5668\u9a71\u52a8\uff08\u5982ChromeDriver\uff09\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install selenium<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\uff0c\u4e0b\u8f7d\u5bf9\u5e94\u7684\u6d4f\u89c8\u5668\u9a71\u52a8\uff0c\u5e76\u5c06\u5176\u8def\u5f84\u6dfb\u52a0\u5230\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\u4e2d\u3002<\/p>\n<\/p>\n<p><h4>\u4f7f\u7528Selenium\u83b7\u53d6\u52a8\u6001\u7f51\u9875\u5185\u5bb9<\/h4>\n<\/p>\n<p><p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\u4ee3\u7801\uff0c\u5c55\u793a\u4e86\u5982\u4f55\u4f7f\u7528Selenium\u83b7\u53d6\u8c46\u74e3\u8bfb\u4e66\u4e0a\u7684\u4e66\u7c4d\u4fe1\u606f\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from selenium import webdriver<\/p>\n<p>from bs4 import BeautifulSoup<\/p>\n<h2><strong>\u8bbe\u7f6e\u6d4f\u89c8\u5668\u9a71\u52a8<\/strong><\/h2>\n<p>driver = webdriver.Chrome()<\/p>\n<h2><strong>\u8bbf\u95ee\u7f51\u9875<\/strong><\/h2>\n<p>url = &#39;https:\/\/book.douban.com\/tag\/\u5c0f\u8bf4&#39;<\/p>\n<p>driver.get(url)<\/p>\n<h2><strong>\u83b7\u53d6\u7f51\u9875\u5185\u5bb9<\/strong><\/h2>\n<p>html_content = driver.page_source<\/p>\n<h2><strong>\u89e3\u6790HTML\u6587\u6863<\/strong><\/h2>\n<p>soup = BeautifulSoup(html_content, &#39;html.parser&#39;)<\/p>\n<h2><strong>\u63d0\u53d6\u4e66\u7c4d\u4fe1\u606f<\/strong><\/h2>\n<p>books = soup.find_all(&#39;div&#39;, class_=&#39;info&#39;)<\/p>\n<p>for book in books:<\/p>\n<p>    title = book.find(&#39;a&#39;).get_text().strip()<\/p>\n<p>    author = book.find(&#39;div&#39;, class_=&#39;pub&#39;).get_text().strip()<\/p>\n<p>    print(f&#39;Title: {title}, Author: {author}&#39;)<\/p>\n<h2><strong>\u5173\u95ed\u6d4f\u89c8\u5668<\/strong><\/h2>\n<p>driver.quit()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u516b\u3001\u5904\u7406\u9a8c\u8bc1\u7801<\/h3>\n<\/p>\n<p><p>\u6709\u4e9b\u7f51\u7ad9\u4f1a\u4f7f\u7528\u9a8c\u8bc1\u7801\u6765\u963b\u6b62\u722c\u866b\u8bbf\u95ee\u3002\u53ef\u4ee5\u4f7f\u7528\u7b2c\u4e09\u65b9\u9a8c\u8bc1\u7801\u8bc6\u522b\u670d\u52a1\uff08\u5982\u6253\u7801\u5e73\u53f0\uff09\u6765\u5904\u7406\u9a8c\u8bc1\u7801\uff0c\u6216\u8005\u901a\u8fc7\u624b\u52a8\u8f93\u5165\u9a8c\u8bc1\u7801\u6765\u7ed5\u8fc7\u9a8c\u8bc1\u3002<\/p>\n<\/p>\n<p><h4>\u4f7f\u7528\u7b2c\u4e09\u65b9\u9a8c\u8bc1\u7801\u8bc6\u522b\u670d\u52a1<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u4f7f\u7528\u7b2c\u4e09\u65b9\u9a8c\u8bc1\u7801\u8bc6\u522b\u670d\u52a1\uff0c\u5c06\u9a8c\u8bc1\u7801\u56fe\u7247\u53d1\u9001\u5230\u8bc6\u522b\u5e73\u53f0\uff0c\u83b7\u53d6\u8bc6\u522b\u7ed3\u679c\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\u4ee3\u7801\uff0c\u5c55\u793a\u4e86\u5982\u4f55\u4f7f\u7528\u7b2c\u4e09\u65b9\u9a8c\u8bc1\u7801\u8bc6\u522b\u670d\u52a1\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import requests<\/p>\n<p>from PIL import Image<\/p>\n<p>from io import BytesIO<\/p>\n<h2><strong>\u83b7\u53d6\u9a8c\u8bc1\u7801\u56fe\u7247<\/strong><\/h2>\n<p>url = &#39;https:\/\/example.com\/captcha&#39;<\/p>\n<p>response = requests.get(url)<\/p>\n<p>image = Image.open(BytesIO(response.content))<\/p>\n<h2><strong>\u5c06\u9a8c\u8bc1\u7801\u56fe\u7247\u53d1\u9001\u5230\u8bc6\u522b\u5e73\u53f0<\/strong><\/h2>\n<p>captcha_response = requests.post(&#39;https:\/\/captcha-recognition-service.com\/api&#39;, files={&#39;file&#39;: image})<\/p>\n<h2><strong>\u83b7\u53d6\u8bc6\u522b\u7ed3\u679c<\/strong><\/h2>\n<p>captcha_text = captcha_response.text<\/p>\n<p>print(f&#39;Captcha: {captcha_text}&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u624b\u52a8\u8f93\u5165\u9a8c\u8bc1\u7801<\/h4>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u53ef\u4ee5\u901a\u8fc7\u624b\u52a8\u8f93\u5165\u9a8c\u8bc1\u7801\u6765\u7ed5\u8fc7\u9a8c\u8bc1\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\u4ee3\u7801\uff0c\u5c55\u793a\u4e86\u5982\u4f55\u624b\u52a8\u8f93\u5165\u9a8c\u8bc1\u7801\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import requests<\/p>\n<h2><strong>\u83b7\u53d6\u9a8c\u8bc1\u7801\u56fe\u7247<\/strong><\/h2>\n<p>url = &#39;https:\/\/example.com\/captcha&#39;<\/p>\n<p>response = requests.get(url)<\/p>\n<p>with open(&#39;captcha.jpg&#39;, &#39;wb&#39;) as f:<\/p>\n<p>    f.write(response.content)<\/p>\n<h2><strong>\u663e\u793a\u9a8c\u8bc1\u7801\u56fe\u7247<\/strong><\/h2>\n<p>from PIL import Image<\/p>\n<p>image = Image.open(&#39;captcha.jpg&#39;)<\/p>\n<p>image.show()<\/p>\n<h2><strong>\u624b\u52a8\u8f93\u5165\u9a8c\u8bc1\u7801<\/strong><\/h2>\n<p>captcha_text = input(&#39;Enter the captcha: &#39;)<\/p>\n<p>print(f&#39;Captcha: {captcha_text}&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e5d\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u53ef\u4ee5\u5229\u7528Python\u722c\u866b\u6765\u641c\u4e66\u3002\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u9700\u8981\u6839\u636e\u76ee\u6807\u7f51\u7ad9\u7684\u5177\u4f53\u60c5\u51b5\uff0c\u7075\u6d3b\u8c03\u6574\u722c\u866b\u4ee3\u7801\uff0c\u5904\u7406\u53cd\u722c\u866b\u673a\u5236\u548c\u52a8\u6001\u7f51\u9875\u7b49\u95ee\u9898\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u5b8c\u6574\u7684\u793a\u4f8b\u4ee3\u7801\uff0c\u5c55\u793a\u4e86\u5982\u4f55\u5229\u7528Python\u722c\u866b\u722c\u53d6\u8c46\u74e3\u8bfb\u4e66\u4e0a\u7684\u4e66\u7c4d\u4fe1\u606f\uff0c\u5e76\u5b58\u50a8\u5230CSV\u6587\u4ef6\u4e2d\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import requests<\/p>\n<p>from bs4 import BeautifulSoup<\/p>\n<p>import csv<\/p>\n<p>import time<\/p>\n<p>headers = {<\/p>\n<p>    &#39;User-Agent&#39;: &#39;Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/91.0.4472.124 Safari\/537.36&#39;<\/p>\n<p>}<\/p>\n<p>url = &#39;https:\/\/book.douban.com\/tag\/\u5c0f\u8bf4&#39;<\/p>\n<p>response = requests.get(url, headers=headers)<\/p>\n<p>html_content = response.text<\/p>\n<p>soup = BeautifulSoup(html_content, &#39;html.parser&#39;)<\/p>\n<p>books = soup.find_all(&#39;div&#39;, class_=&#39;info&#39;)<\/p>\n<p>with open(&#39;books.csv&#39;, &#39;w&#39;, newline=&#39;&#39;, encoding=&#39;utf-8&#39;) as csvfile:<\/p>\n<p>    fieldnames = [&#39;Title&#39;, &#39;Author&#39;]<\/p>\n<p>    writer = csv.DictWriter(csvfile, fieldnames=fieldnames)<\/p>\n<p>    writer.writeheader()<\/p>\n<p>    for book in books:<\/p>\n<p>        title = book.find(&#39;a&#39;).get_text().strip()<\/p>\n<p>        author = book.find(&#39;div&#39;, class_=&#39;pub&#39;).get_text().strip()<\/p>\n<p>        writer.writerow({&#39;Title&#39;: title, &#39;Author&#39;: author})<\/p>\n<p>        # \u8bbe\u7f6e\u5ef6\u65f6<\/p>\n<p>        time.sleep(2)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u4e0a\u8ff0\u4ee3\u7801\uff0c\u53ef\u4ee5\u6210\u529f\u722c\u53d6\u8c46\u74e3\u8bfb\u4e66\u4e0a\u7684\u4e66\u7c4d\u4fe1\u606f\uff0c\u5e76\u5c06\u5176\u5b58\u50a8\u5230CSV\u6587\u4ef6\u4e2d\u3002\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u53ef\u4ee5\u6839\u636e\u9700\u8981\uff0c\u8fdb\u4e00\u6b65\u4f18\u5316\u548c\u6269\u5c55\u722c\u866b\u4ee3\u7801\uff0c\u5b9e\u73b0\u66f4\u591a\u529f\u80fd\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u4f7f\u7528Python\u722c\u866b\u83b7\u53d6\u7279\u5b9a\u4e66\u7c4d\u7684\u4fe1\u606f\uff1f<\/strong><br \/>\u4f7f\u7528Python\u722c\u866b\u83b7\u53d6\u7279\u5b9a\u4e66\u7c4d\u7684\u4fe1\u606f\u901a\u5e38\u6d89\u53ca\u51e0\u4e2a\u6b65\u9aa4\u3002\u9996\u5148\uff0c\u60a8\u9700\u8981\u9009\u62e9\u4e00\u4e2a\u5408\u9002\u7684\u7f51\u9875\u4f5c\u4e3a\u6570\u636e\u6e90\u3002\u63a5\u7740\uff0c\u4f7f\u7528\u5982Requests\u5e93\u83b7\u53d6\u7f51\u9875\u5185\u5bb9\uff0c\u5e76\u5229\u7528BeautifulSoup\u6216lxml\u7b49\u5e93\u89e3\u6790HTML\u6587\u6863\u3002\u89e3\u6790\u540e\uff0c\u60a8\u53ef\u4ee5\u63d0\u53d6\u4e66\u540d\u3001\u4f5c\u8005\u3001\u51fa\u7248\u4fe1\u606f\u7b49\u6570\u636e\uff0c\u6700\u540e\u5c06\u6570\u636e\u4fdd\u5b58\u5230CSV\u6587\u4ef6\u6216\u6570\u636e\u5e93\u4e2d\uff0c\u4fbf\u4e8e\u540e\u7eed\u5206\u6790\u548c\u7ba1\u7406\u3002<\/p>\n<p><strong>\u5728\u5229\u7528Python\u722c\u866b\u641c\u4e66\u65f6\u9700\u8981\u6ce8\u610f\u54ea\u4e9b\u6cd5\u5f8b\u548c\u9053\u5fb7\u95ee\u9898\uff1f<\/strong><br \/>\u5728\u4f7f\u7528Python\u722c\u866b\u8fdb\u884c\u4e66\u7c4d\u641c\u7d22\u65f6\uff0c\u9075\u5b88\u6cd5\u5f8b\u548c\u9053\u5fb7\u89c4\u8303\u662f\u975e\u5e38\u91cd\u8981\u7684\u3002\u9996\u5148\uff0c\u786e\u4fdd\u9075\u5faa\u7f51\u7ad9\u7684robots.txt\u6587\u4ef6\u4e2d\u5217\u51fa\u7684\u722c\u866b\u89c4\u5219\uff0c\u4ee5\u514d\u8fdd\u53cd\u7f51\u7ad9\u7684\u4f7f\u7528\u6761\u6b3e\u3002\u6b64\u5916\uff0c\u907f\u514d\u5bf9\u76ee\u6807\u7f51\u7ad9\u9020\u6210\u8fc7\u5927\u8d1f\u62c5\uff0c\u4e0d\u8981\u9891\u7e41\u8bf7\u6c42\u540c\u4e00\u9875\u9762\uff0c\u9002\u5f53\u8bbe\u7f6e\u8bf7\u6c42\u95f4\u9694\u3002\u8fd8\u8981\u6ce8\u610f\u7248\u6743\u95ee\u9898\uff0c\u5408\u7406\u4f7f\u7528\u83b7\u53d6\u7684\u6570\u636e\uff0c\u5c3d\u91cf\u907f\u514d\u672a\u7ecf\u6388\u6743\u7684\u5185\u5bb9\u91c7\u96c6\u3002<\/p>\n<p><strong>\u5982\u4f55\u63d0\u9ad8Python\u722c\u866b\u7684\u6548\u7387\u4ee5\u4fbf\u5feb\u901f\u641c\u4e66\uff1f<\/strong><br \/>\u63d0\u9ad8Python\u722c\u866b\u6548\u7387\u7684\u65b9\u5f0f\u6709\u5f88\u591a\u3002\u4f7f\u7528\u5f02\u6b65\u8bf7\u6c42\u5e93\u5982<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>ohttp\u53ef\u4ee5\u663e\u8457\u52a0\u5feb\u6570\u636e\u6293\u53d6\u901f\u5ea6\u3002\u6b64\u5916\uff0c\u5408\u7406\u8bbe\u8ba1\u722c\u866b\u67b6\u6784\uff0c\u4f7f\u7528\u591a\u7ebf\u7a0b\u6216\u591a\u8fdb\u7a0b\u6280\u672f\u4e5f\u53ef\u4ee5\u663e\u8457\u63d0\u9ad8\u6548\u7387\u3002\u5bf9\u6293\u53d6\u7684\u6570\u636e\u8fdb\u884c\u7f13\u5b58\uff0c\u907f\u514d\u91cd\u590d\u8bf7\u6c42\u540c\u4e00\u6570\u636e\uff0c\u80fd\u591f\u8282\u7701\u65f6\u95f4\u548c\u8d44\u6e90\u3002\u6700\u540e\uff0c\u4f18\u5316\u89e3\u6790\u8fc7\u7a0b\uff0c\u9009\u62e9\u9ad8\u6548\u7684\u89e3\u6790\u5e93\uff0c\u80fd\u591f\u52a0\u901f\u6570\u636e\u63d0\u53d6\u7684\u8fc7\u7a0b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5229\u7528Python\u722c\u866b\u6765\u641c\u4e66\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u51e0\u4e2a\u6b65\u9aa4\u6765\u5b9e\u73b0\uff1a\u9009\u62e9\u76ee\u6807\u7f51\u7ad9\u3001\u5206\u6790\u7f51\u9875\u7ed3\u6784\u3001\u7f16\u5199\u722c\u866b\u4ee3\u7801\u3001\u89e3\u6790\u548c\u63d0\u53d6\u6570 [&hellip;]","protected":false},"author":3,"featured_media":1187004,"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\/1186995"}],"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=1186995"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1186995\/revisions"}],"predecessor-version":[{"id":1187005,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1186995\/revisions\/1187005"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1187004"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1186995"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1186995"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1186995"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}