{"id":92643,"date":"2026-08-10T20:08:50","date_gmt":"2026-08-10T12:08:50","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/92643.html"},"modified":"2026-08-10T20:08:50","modified_gmt":"2026-08-10T12:08:50","slug":"python%ef%bc%9a%e5%ad%97%e7%ac%a6%e4%b8%b2%e4%bc%aa%e8%a3%85%e5%88%97%e8%a1%a8%e3%80%81%e5%ad%97%e7%ac%a6%e4%b8%b2%e5%ba%8f%e5%88%97%e5%8c%96%e5%af%b9%e8%b1%a1%e8%a7%a3%e6%9e%90%e8%b8%a9%e5%9d%91","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/92643.html","title":{"rendered":"Python\uff1a\u5b57\u7b26\u4e32\u4f2a\u88c5\u5217\u8868\u3001\u5b57\u7b26\u4e32\u5e8f\u5217\u5316\u5bf9\u8c61\u89e3\u6790\u8e29\u5751\u5b9e\u6218"},"content":{"rendered":"<h3 id=\"%E5%89%8D%E8%A8%80\">\u524d \u8a00<\/h3>\n<p>\u5728\u505a AI \u5e94\u7528\u5f00\u53d1\u65f6&#xff0c;\u6211\u4eec\u7ecf\u5e38\u4f1a\u62ff\u5230\u5404\u79cd \u201c\u770b\u8d77\u6765\u662f\u5bf9\u8c61&#xff0c;\u5b9e\u9645\u662f\u5b57\u7b26\u4e32\u201d \u7684\u6570\u636e&#xff1a;<\/p>\n<li>\u914d\u7f6e\u3001\u63a5\u53e3\u8fd4\u56de&#xff1a;&#039;[&#034;qwen-turbo&#034;,&#034;qwen-plus&#034;,&#034;deepseek&#034;]&#039;&#xff0c;JSON \u683c\u5f0f\u7684\u5b57\u7b26\u4e32\u5217\u8868&#xff1b;<\/li>\n<li>\u65e5\u5fd7\u6253\u5370 \/ \u7f13\u5b58\u5b57\u7b26\u4e32&#xff1a;\u628aList[Document]\u76f4\u63a5\u8f6c\u5b57\u7b26\u4e32&#xff0c;\u5f97\u5230\u4e00\u957f\u4e32&#034;[Document(metadata&#061;{&#8230;}, page_content&#061;&#039;&#8230;&#039;), &#8230;]&#034;\u3002<\/li>\n<p>\u65b0\u624b\u5bb9\u6613\u8e29\u5751&#xff1a;\u76f4\u63a5eval()\u3001\u76f4\u63a5split()\u66b4\u529b\u5207\u5272&#xff0c;\u8981\u4e48\u6709\u5b89\u5168\u6f0f\u6d1e&#xff0c;\u8981\u4e48\u89e3\u6790\u4e0d\u7a33\u5b9a\u3002\u4e0b\u9762\u4e24\u4e2a\u6848\u4f8b\u7531\u6d45\u5165\u6df1\u5206\u6790\u3002<\/p>\n<hr \/>\n<h3 id=\"%E6%A1%88%E4%BE%8B%E4%B8%80%EF%BC%9AJSON%20%E6%A0%BC%E5%BC%8F%E5%AD%97%E7%AC%A6%E4%B8%B2%E8%BD%AC%20List\">\u6848\u4f8b\u4e00&#xff1a;JSON \u683c\u5f0f\u5b57\u7b26\u4e32\u8f6c List<\/h3>\n<p>\u8f93\u5165\u5b57\u7b26\u4e32&#xff1a;<\/p>\n<p>raw_str &#061;&#039;[&#034;qwen-turbo&#034;,&#034;qwen-plus&#034;,&#034;deepseek&#034;]&#039;<\/p>\n<p>\u8fd9\u4e2a\u5b57\u7b26\u4e32\u662f\u6807\u51c6 JSON \u6570\u7ec4\u5b57\u7b26\u4e32\u3002<\/p>\n<h4 id=\"%E2%9D%8C%20%E9%94%99%E8%AF%AF%E5%86%99%E6%B3%95%201%EF%BC%9A%E7%9B%B4%E6%8E%A5%20split%20%E5%88%86%E5%89%B2\">\u274c \u9519\u8bef\u5199\u6cd5 1&#xff1a;\u76f4\u63a5 split \u5206\u5272<\/h4>\n<p># \u4e0d\u63a8\u8350&#xff01;\u5982\u679c\u5b57\u7b26\u4e32\u5185\u90e8\u5305\u542b\u9017\u53f7\u3001\u5f15\u53f7\u76f4\u63a5\u5d29\u6389<br \/>\nres &#061; raw_str.strip(&#039;[]&#039;).split(&#039;,&#039;)<\/p>\n<p>\u95ee\u9898&#xff1a;\u4e00\u65e6\u5143\u7d20\u5185\u90e8\u51fa\u73b0\u9017\u53f7\u3001\u8f6c\u4e49\u5f15\u53f7&#xff0c;\u5206\u5272\u76f4\u63a5\u51fa\u9519&#xff0c;\u9c81\u68d2\u6027\u6781\u5dee\u3002<\/p>\n<h4 id=\"%E2%9D%8C%20%E9%94%99%E8%AF%AF%E5%86%99%E6%B3%95%202%EF%BC%9Aeval%20%E6%89%A7%E8%A1%8C\">\u274c \u9519\u8bef\u5199\u6cd5 2&#xff1a;eval \u6267\u884c<\/h4>\n<p>res &#061; eval(raw_str)<\/p>\n<p>\u867d\u7136\u8fd9\u91cc\u53ef\u4ee5\u8dd1\u901a&#xff0c;eval \u6781\u5ea6\u5371\u9669&#xff1a;\u5982\u679c\u5b57\u7b26\u4e32\u6765\u6e90\u662f\u7528\u6237\u8f93\u5165&#xff0c;\u4f20\u5165\u6076\u610f\u4ee3\u7801&#xff0c;\u4f1a\u76f4\u63a5\u6267\u884c\u4efb\u610f\u7cfb\u7edf\u547d\u4ee4&#xff0c;\u751f\u4ea7\u73af\u5883\u4e25\u7981\u4f7f\u7528\u3002<\/p>\n<h4 id=\"%E2%9C%85%20%E6%A0%87%E5%87%86%E6%96%B9%E6%A1%88%EF%BC%9A%E4%BD%BF%E7%94%A8json.loads()\">\u2705 \u6807\u51c6\u65b9\u6848&#xff1a;\u4f7f\u7528json.loads()<\/h4>\n<p>import json<\/p>\n<p>raw_str &#061;&#039;[&#034;qwen-turbo&#034;,&#034;qwen-plus&#034;,&#034;deepseek&#034;]&#039;<br \/>\nmodel_list: list &#061; json.loads(raw_str)<br \/>\nprint(model_list)<br \/>\n# [&#039;qwen-turbo&#039;, &#039;qwen-plus&#039;, &#039;deepseek&#039;]<br \/>\nprint(type(model_list)) # &lt;class &#039;list&#039;&gt;<\/p>\n<p>&#x1f4a1;\u77e5\u8bc6\u70b9&#xff1a;<\/p>\n<ul>\n<li>json.loads()&#xff1a;\u5b89\u5168\u7684 JSON \u5b57\u7b26\u4e32\u53cd\u5e8f\u5217\u5316&#xff0c;\u53ea\u89e3\u6790 JSON \u6570\u636e&#xff0c;\u4e0d\u4f1a\u6267\u884c\u4ee3\u7801&#xff1b;<\/li>\n<li>json.dumps()&#xff1a;\u5bf9\u8c61\u8f6c\u4e3a JSON \u5b57\u7b26\u4e32\u3002<\/li>\n<\/ul>\n<p>\u8fb9\u754c\u63d0\u9192&#xff1a;JSON \u5b57\u7b26\u4e32\u5fc5\u987b\u662f\u53cc\u5f15\u53f7&#xff0c;\u5355\u5f15\u53f7\u7684\u5b57\u7b26\u4e32 json \u5e93\u4f1a\u62a5\u9519\u3002\u5982\u679c\u9047\u5230\u5355\u5f15\u53f7 JSON&#xff0c;\u9700\u8981\u7279\u6b8a\u5904\u7406&#xff0c;\u4e0d\u8981\u76f4\u63a5\u4e22\u7ed9 eval\u3002<\/p>\n<hr \/>\n<h3 id=\"%E6%A1%88%E4%BE%8B%E4%BA%8C%EF%BC%9A%E5%AD%97%E7%AC%A6%E4%B8%B2%E5%8C%96%E7%9A%84%20LangChain%20Document%20%E5%AF%B9%E8%B1%A1%EF%BC%8C%E6%8F%90%E5%8F%96%20page\">\u6848\u4f8b\u4e8c&#xff1a;\u5b57\u7b26\u4e32\u5316\u7684 LangChain Document \u5bf9\u8c61&#xff0c;\u63d0\u53d6 page<\/h3>\n<p>\u95ee\u9898\u80cc\u666f&#xff1a; \u5f53\u4f60\u6267\u884cstr([Document(&#8230;), Document(&#8230;)])&#xff0c;\u5c31\u4f1a\u5f97\u5230\u9898\u76ee\u4e2d\u7684\u8fd9\u4e00\u5927\u6bb5\u5b57\u7b26\u4e32\u3002 \u6ce8\u610f&#xff1a;\u8fd9\u4e0d\u662f JSON&#xff01;\u8fd9\u662f Python \u5bf9\u8c61\u6253\u5370\u8f93\u51fa\u7684\u6587\u672c\u8868\u793a\u3002<\/p>\n<p>&#034;[Document(metadata&#061;{&#039;pk&#039;: 12, &#039;page&#039;: 2}, page_content&#061;&#039;xxx&#039;), Document(&#8230;)]&#034;<\/p>\n<p>\u6211\u4eec\u7684\u76ee\u6807&#xff1a;\u63d0\u53d6\u6bcf\u4e00\u4e2a Document \u91cc\u9762metadata[&#034;page&#034;]\u9875\u7801&#xff0c;\u5e76\u4e14\u62fc\u63a5page_content\u6587\u672c\u3002<\/p>\n<h4 id=\"%E2%9D%8C%20%E4%B8%BA%E4%BB%80%E4%B9%88%E4%B8%8D%E8%83%BD%E7%94%A8%20json.loads%EF%BC%9F\">\u274c \u4e3a\u4ec0\u4e48\u4e0d\u80fd\u7528 json.loads&#xff1f;<\/h4>\n<li>\u91cc\u9762\u662fDocument(&#8230;)&#xff0c;\u8fd9\u662f Python \u7c7b\u5b9e\u4f8b&#xff0c;JSON \u6ca1\u6709 Document \u7c7b\u578b&#xff1b;<\/li>\n<li>\u5b57\u5178\u5185\u90e8\u4f7f\u7528\u5355\u5f15\u53f7{&#039;pk&#039;:12}&#xff0c;JSON \u89c4\u8303\u5f3a\u5236\u53cc\u5f15\u53f7&#xff1b; \u76f4\u63a5json.loads()\u76f4\u63a5\u629b\u51fa\u5f02\u5e38&#xff0c;\u5b8c\u5168\u65e0\u6cd5\u89e3\u6790\u3002<\/li>\n<h4 id=\"%E2%9A%A0%EF%B8%8F%20%E4%B8%8D%E6%8E%A8%E8%8D%90%E6%96%B9%E6%A1%88%EF%BC%9Aeval\">\u26a0\ufe0f \u4e0d\u63a8\u8350\u65b9\u6848&#xff1a;eval<\/h4>\n<p># \u4ec5\u672c\u5730\u8c03\u8bd5\u53ef\u4ee5\u770b\u6548\u679c&#xff0c;\u751f\u4ea7\u7edd\u5bf9\u7981\u6b62&#xff01;<br \/>\ndoc_str &#061; &#034;&#034;&#034;[Document(metadata&#061;{&#039;pk&#039;: 12, &#039;page&#039;: 2}, page_content&#061;&#039;xxx&#039;), &#8230;]&#034;&#034;&#034;<br \/>\ndocs &#061; eval(doc_str)<\/p>\n<ul>\n<li>\u4f18\u70b9&#xff1a;\u4e00\u884c\u4ee3\u7801\u76f4\u63a5\u8fd8\u539fList[Document]\u5bf9\u8c61&#xff1b;<\/li>\n<li>\u81f4\u547d\u98ce\u9669&#xff1a;\u5982\u679c\u5b57\u7b26\u4e32\u6765\u81ea\u5916\u90e8\u8f93\u5165&#xff0c;\u653b\u51fb\u8005\u53ef\u4ee5\u6ce8\u5165\u6076\u610f Python \u4ee3\u7801&#xff0c;\u670d\u52a1\u5668\u76f4\u63a5\u6ca6\u9677\u3002<\/li>\n<\/ul>\n<p>\u9002\u7528\u573a\u666f&#xff1a;\u4ec5\u9650\u672c\u5730\u8c03\u8bd5\u3001\u81ea\u5df1\u751f\u6210\u7684\u65e5\u5fd7\u5b57\u7b26\u4e32&#xff1b;\u63a5\u53e3\u3001\u7528\u6237\u8f93\u5165\u7edd\u5bf9\u7981\u7528 eval\u3002<\/p>\n<h4 id=\"%E2%9C%85%20%E6%96%B9%E6%A1%88%20A%EF%BC%9A%E5%AE%89%E5%85%A8%E8%A7%A3%E6%9E%90%20%E2%80%94%E2%80%94%20pyparsing%20%2Fast.literal_eval%EF%BC%88%E6%8E%A8%E8%8D%90%EF%BC%89\">\u2705 \u65b9\u6848 A&#xff1a;\u5b89\u5168\u89e3\u6790 \u2014\u2014 pyparsing \/ast.literal_eval&#xff08;\u63a8\u8350&#xff09;<\/h4>\n<p>ast.literal_eval \u662f\u5b89\u5168\u7248\u672c\u7684 eval&#xff0c;\u53ea\u89e3\u6790 Python \u5b57\u9762\u91cf&#xff1a;\u5217\u8868\u3001\u5b57\u5178\u3001\u5bf9\u8c61\u8c03\u7528\u5f62\u5f0f&#xff0c;\u4e0d\u4f1a\u6267\u884c\u51fd\u6570\u548c\u6076\u610f\u4ee3\u7801\u3002 \u4f46\u662f\u6ce8\u610f&#xff1a;ast.literal_eval\u53ef\u4ee5\u89e3\u6790Dict\u3001List&#xff0c;\u4f46\u662f\u4e0d\u80fd\u76f4\u63a5\u5b9e\u4f8b\u5316 Document \u7c7b&#xff0c;\u9047\u5230Document(&#8230;)\u4f1a\u62a5\u9519\u3002<\/p>\n<p>\u6240\u4ee5\u5206\u4e24\u6761\u8def\u7ebf&#xff1a;<\/p>\n<li>\u5982\u679c\u4f60\u624b\u4e0a\u6709 Document \u7c7b&#xff08;\u5df2\u7ecf\u5bfc\u5165 langchain \u7684 Document&#xff09;&#xff0c;\u53ef\u4ee5\u7ed3\u5408 ast \u505a\u6709\u9650\u89e3\u6790&#xff1b;<\/li>\n<li>\u5982\u679c\u53ea\u6709\u7eaf\u5b57\u7b26\u4e32\u6587\u672c&#xff0c;\u6ca1\u6709 Document \u7c7b&#xff0c;\u6211\u4eec\u505a\u6b63\u5219\u63d0\u53d6&#xff0c;\u53ea\u62ff\u6211\u4eec\u5173\u5fc3\u7684page\u548cpage_content\u3002<\/li>\n<h5 id=\"%E6%96%B9%E6%A1%88%20A%E2%80%911%EF%BC%9A%E6%AD%A3%E5%88%99%E6%8F%90%E5%8F%96%EF%BC%88%E5%8F%AA%E6%8B%BF%E6%95%B0%E6%8D%AE%EF%BC%8C%E4%B8%8D%E9%9C%80%E8%A6%81%E8%BF%98%E5%8E%9F%20Document%20%E5%AF%B9%E8%B1%A1%EF%BC%8C%E6%9C%80%E7%A8%B3%E5%A6%A5%EF%BC%89\">\u65b9\u6848 A\u20111&#xff1a;\u6b63\u5219\u63d0\u53d6&#xff08;\u53ea\u62ff\u6570\u636e&#xff0c;\u4e0d\u9700\u8981\u8fd8\u539f Document \u5bf9\u8c61&#xff0c;\u6700\u7a33\u59a5&#xff09;<\/h5>\n<p>\u4e0d\u9700\u8981\u5bfc\u5165 langchain&#xff0c;\u4e0d\u5b9e\u4f8b\u5316\u5bf9\u8c61&#xff0c;\u6b63\u5219\u628apage\u6570\u5b57\u3001page_content\u5185\u5bb9\u63d0\u53d6\u51fa\u6765\u3002<\/p>\n<p>import re<\/p>\n<p>doc_str &#061; &#034;&#034;&#034;[Document(metadata&#061;{&#039;pk&#039;: 12, &#039;page&#039;: 2}, page_content&#061;&#039;2. \u8d39\u2f64\u62a5\u9500&#xff1a;&#8230;&#039;), Document(metadata&#061;{&#039;pk&#039;: 27, &#039;page&#039;: 2}, page_content&#061;&#039;2. \u8d39\u2f64\u62a5\u9500:&#8230;&#039;), Document(metadata&#061;{&#039;pk&#039;: 14, &#039;page&#039;: 3}, page_content&#061;&#039;3. \u6700\u540e\u8b66\u544a&#xff1a;&#8230;&#039;)]&#034;&#034;&#034;<\/p>\n<p># \u6b63\u5219\u5339\u914d metadata&#061;{&#039;xxx&#039;,&#039;page&#039;: N}&#xff0c;\u63d0\u53d6page\u6570\u5b57<br \/>\npage_pattern &#061; re.compile(r&#034;metadata&#061;\\\\{.*?&#039;page&#039;:\\\\s*(\\\\d&#043;)&#034;)<br \/>\n# \u63d0\u53d6page_content\u7684\u6587\u672c<br \/>\ncontent_pattern &#061; re.compile(r&#034;page_content&#061;&#039;(.*?)&#039;\\\\)&#034;, re.S)<\/p>\n<p>pages &#061; page_pattern.findall(doc_str)<br \/>\ncontents &#061; content_pattern.findall(doc_str)<\/p>\n<p># pages\u662f\u5b57\u7b26\u4e32\u6570\u5b57&#xff0c;\u8f6cint<br \/>\npage_nums &#061; [int(p) for p in pages]<br \/>\nfull_text &#061; &#034;\\\\n&#034;.join(contents)<\/p>\n<p>print(&#034;\u63d0\u53d6\u5230\u9875\u7801\u5217\u8868&#xff1a;&#034;, page_nums)<br \/>\nprint(&#034;\u62fc\u63a5\u540e\u7684\u5168\u90e8\u6587\u6863\u6587\u672c:\\\\n&#034;, full_text)<\/p>\n<ul>\n<li>\u4f18\u70b9&#xff1a;\u96f6\u4f9d\u8d56\u3001\u5b89\u5168&#xff0c;\u4e0d\u6015\u6076\u610f\u8f93\u5165&#xff0c;\u4e0d\u9700\u8981\u5bfc\u5165 Document \u7c7b&#xff1b;<\/li>\n<li>\u7f3a\u70b9&#xff1a;\u5b57\u7b26\u4e32\u683c\u5f0f\u5982\u679c\u53d1\u751f\u53d8\u5316&#xff08;\u7a7a\u683c\u3001\u6362\u884c&#xff09;\u9700\u8981\u5fae\u8c03\u6b63\u5219&#xff1b;\u9002\u5408\u65e5\u5fd7\u3001\u7f13\u5b58\u5b57\u7b26\u4e32\u89e3\u6790\u573a\u666f\u3002<\/li>\n<\/ul>\n<h5 id=\"%E6%96%B9%E6%A1%88%20A%E2%80%912%EF%BC%9A%E5%8F%97%E6%8E%A7%20eval%20%2Fast.literal_eval%20%2B%20Document%20%E7%B1%BB%EF%BC%88%E4%BB%85%E9%99%90%E5%8F%AF%E4%BF%A1%E5%86%85%E9%83%A8%E6%95%B0%E6%8D%AE%E6%BA%90%EF%BC%89\">\u65b9\u6848 A\u20112&#xff1a;\u53d7\u63a7 eval \/ast.literal_eval &#043; Document \u7c7b&#xff08;\u4ec5\u9650\u53ef\u4fe1\u5185\u90e8\u6570\u636e\u6e90&#xff09;<\/h5>\n<p>\u26a0\ufe0f \u524d\u63d0&#xff1a;\u5b57\u7b26\u4e32\u6765\u6e90\u662f\u7a0b\u5e8f\u81ea\u5df1\u6253\u5370\u8f93\u51fa\u7684\u65e5\u5fd7&#xff0c;\u4e0d\u662f\u7528\u6237\u8f93\u5165\u3002<\/p>\n<p>from langchain_core.documents import Document<br \/>\nimport ast<\/p>\n<p>raw_s &#061; &#034;&#034;&#034;[Document(metadata&#061;{&#039;pk&#039;: 12, &#039;page&#039;: 2}, page_content&#061;&#039;demo&#039;),Document(metadata&#061;{&#039;pk&#039;: 14, &#039;page&#039;:3}, page_content&#061;&#039;demo2&#039;)]&#034;&#034;&#034;<\/p>\n<p># ast.literal_eval \u65e0\u6cd5\u76f4\u63a5\u5904\u7406Document(&#8230;)&#xff0c;\u6240\u4ee5eval\u5728\u8fd9\u91cc&#xff0c;\u4ec5\u9650\u53ef\u4fe1\u6570\u636e\u6e90<br \/>\ndocs &#061; eval(raw_s)<\/p>\n<p>page_list &#061; [doc.metadata[&#034;page&#034;] for doc in docs]<br \/>\nall_text &#061; &#034;\\\\n&#034;.join([doc.page_content for doc in docs])<\/p>\n<p>print(page_list)<br \/>\nprint(all_text)<\/p>\n<p>&#x1f4a1;\u91cd\u8981\u63d0\u9192&#xff1a;<\/p>\n<p>ast.literal_eval\u4e0d\u652f\u6301\u7c7b\u5b9e\u4f8b\u5316\u8868\u8fbe\u5f0fDocument()&#xff0c;\u6240\u4ee5\u8fd9\u79cd\u6253\u5370\u51fa\u6765\u7684\u5bf9\u8c61\u5b57\u7b26\u4e32&#xff0c;ast.literal_eval\u4f1a\u629b\u5f02\u5e38&#xff0c;\u8fd9\u79cd\u573a\u666f\u4e0b ast \u4e0d\u80fd\u66ff\u4ee3 eval\u3002 \u8bb0\u4f4f\u5206\u754c\u7ebf&#xff1a;\u53ea\u8981\u6587\u672c\u6765\u81ea\u5916\u90e8\u7528\u6237\u8f93\u5165&#xff0c;\u575a\u51b3\u4e0d\u80fd eval\u3002<\/p>\n<h4 id=\"%E2%9C%85%20%E6%9C%80%E4%BD%B3%E5%B7%A5%E7%A8%8B%E5%AE%9E%E8%B7%B5%EF%BC%9A%E4%B8%8D%E8%A6%81%E6%8A%8Astr(list%5BDocument%5D)%E5%BD%93%E5%81%9A%E6%8C%81%E4%B9%85%E5%8C%96%E5%AD%98%E5%82%A8\">\u2705 \u6700\u4f73\u5de5\u7a0b\u5b9e\u8df5&#xff1a;\u4e0d\u8981\u628astr(list[Document])\u5f53\u505a\u6301\u4e45\u5316\u5b58\u50a8<\/h4>\n<p>\u5f88\u591a\u4eba\u8e29\u5751\u6839\u6e90&#xff1a;\u628astr(docs)\u76f4\u63a5\u5b58\u6570\u636e\u5e93\u3001\u7f13\u5b58\u3002\u8fd9\u662f\u9519\u8bef\u505a\u6cd5&#xff01; LangChain \u539f\u751f\u63d0\u4f9b\u5e8f\u5217\u5316\u65b9\u6cd5&#xff1a;<\/p>\n<p>from langchain_core.documents import Document<\/p>\n<p>docs: list[Document] &#061; [&#8230;]<br \/>\n# \u5bf9\u8c61\u8f6c\u53ef\u5e8f\u5217\u5316\u5b57\u5178\u5217\u8868<br \/>\ndict_list &#061; [doc.model_dump() for doc in docs]<\/p>\n<p># \u4fdd\u5b58\u4e3ajson\u5b57\u7b26\u4e32<br \/>\nimport json<br \/>\njson_str &#061; json.dumps(dict_list, ensure_ascii&#061;False)<\/p>\n<p># \u8fd8\u539f\u56de\u6765<br \/>\nloaded_dicts &#061; json.loads(json_str)<br \/>\nrestore_docs &#061; [Document(**item) for item in loaded_dicts]<\/p>\n<p>\u2705 \u5b58\u7684\u65f6\u5019\u8f6c\u6807\u51c6 JSON&#xff0c;\u8bfb\u53d6\u7684\u65f6\u5019\u518d\u91cd\u5efa Document \u5bf9\u8c61&#xff0c;\u4ece\u6839\u6e90\u907f\u514d\u8fd9\u79cd\u8be1\u5f02\u7684 \u201c\u5bf9\u8c61\u6253\u5370\u5b57\u7b26\u4e32\u201d\u3002<\/p>\n<p>\u8fd9\u624d\u662f\u751f\u4ea7\u73af\u5883\u6807\u51c6\u505a\u6cd5&#xff0c;\u4e0d\u8981\u628a\u5bf9\u8c61 print \u51fa\u6765\u7684\u6587\u672c\u62ff\u6765\u89e3\u6790\u3002<\/p>\n<hr \/>\n<h3 id=\"%E6%A0%B8%E5%BF%83%E6%80%BB%E7%BB%93%E5%AF%B9%E7%85%A7%E8%A1%A8\">\u6838\u5fc3\u603b\u7ed3\u5bf9\u7167\u8868<\/h3>\n<table>\n<tr>\u573a\u666f\u8f93\u5165\u6837\u4f8b\u63a8\u8350\u65b9\u6848\u7981\u6b62<\/tr>\n<tbody>\n<tr>\n<td>\u6807\u51c6 JSON \u6570\u7ec4\u5b57\u7b26\u4e32<\/td>\n<td>&#039;[&#034;a&#034;,&#034;b&#034;]&#039;<\/td>\n<td>json.loads()<\/td>\n<td>eval\u3001split \u7c97\u66b4\u5206\u5272<\/td>\n<\/tr>\n<tr>\n<td>Python \u6253\u5370\u8f93\u51fa\u5bf9\u8c61\u5b57\u7b26\u4e32 [Document(&#8230;)]<\/td>\n<td>str([Document()])<\/td>\n<td>1. \u4f18\u5148\u4f7f\u7528 model_dump \u505a\u6807\u51c6 JSON \u5e8f\u5217\u5316&#xff1b;2. \u672c\u5730\u8c03\u8bd5\u53ef\u4fe1\u6570\u636e\u7528 eval&#xff1b;3. \u5916\u90e8\u6765\u6e90\u4f7f\u7528\u6b63\u5219\u63d0\u53d6<\/td>\n<td>\u7528\u6237\u8f93\u5165\u4e0b\u4f7f\u7528 eval<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4 id=\"%E5%85%B3%E9%94%AE%E5%AE%89%E5%85%A8%E5%8E%9F%E5%88%99\">\u5173\u952e\u5b89\u5168\u539f\u5219<\/h4>\n<li>\u4f46\u51e1\u5b57\u7b26\u4e32\u6765\u81ea\u7528\u6237\u3001\u63a5\u53e3\u8bf7\u6c42\u3001\u5916\u90e8\u7f51\u7edc&#xff0c;\u6c38\u8fdc\u4e0d\u8981\u8c03\u7528eval()&#xff1b;<\/li>\n<li>\u5c3d\u91cf\u4e0d\u8981\u4f9d\u8d56str(\u5bf9\u8c61)\u7684\u8f93\u51fa\u505a\u89e3\u6790&#xff0c;\u6253\u5370\u8f93\u51fa\u662f\u7ed9\u4eba\u770b\u7684&#xff0c;\u4e0d\u662f\u7528\u6765\u7a0b\u5e8f\u89e3\u6790&#xff1b;<\/li>\n<li>\u5bf9\u8c61\u6301\u4e45\u5316&#xff0c;\u4f18\u5148\u8f6c\u4e3a\u6807\u51c6 JSON \u7ed3\u6784&#xff0c;\u907f\u514d\u540e\u9762\u5404\u79cd\u5947\u8469\u89e3\u6790\u96be\u9898\u3002<\/li>\n<h4 id=\"%E6%8B%93%E5%B1%95%E6%80%9D%E8%80%83\">\u62d3\u5c55\u601d\u8003<\/h4>\n<p>1\ufe0f\u20e3 \u4ec0\u4e48\u65f6\u5019\u7528ast.literal_eval&#xff1f; \u5f53\u4f60\u62ff\u5230\u7684\u5b57\u7b26\u4e32\u662f\u5355\u5f15\u53f7\u7684 python \u5b57\u9762\u91cf&#xff0c;\u6bd4\u5982&#034;{&#039;name&#039;:&#039;test&#039;}&#034;&#xff0c;\u4e0d\u662f\u6807\u51c6 JSON&#xff0c;\u53ef\u4ee5\u4f7f\u7528ast.literal_eval\u5b89\u5168\u89e3\u6790\u5b57\u5178&#xff0c;\u5b83\u53ef\u4ee5\u5904\u7406\u5355\u5f15\u53f7\u5b57\u5178&#xff0c;\u4e14\u4e0d\u4f1a\u6267\u884c\u4ee3\u7801\u3002<\/p>\n<p>import ast<br \/>\nd &#061; ast.literal_eval(&#034;{&#039;page&#039;: 2}&#034;)<\/p>\n<p>2\ufe0f\u20e3 RAG \u5f00\u53d1\u4e2d\u5f88\u591a\u5751\u90fd\u6765\u81ea\u5e8f\u5217\u5316&#xff1a;\u5411\u91cf\u5e93\u8fd4\u56de Document\u3001LLM \u8f93\u51fa\u5b57\u7b26\u4e32\u3001\u7f13\u5b58\u6570\u636e&#xff0c;\u4e00\u5b9a\u8981\u505a\u597d\u8fb9\u754c\u5904\u7406\u3002<\/p>\n<h3 id=\"%E5%AE%8C%E6%95%B4%E5%8F%AF%E8%BF%90%E8%A1%8C%E4%BB%A3%E7%A0%81%E6%B1%87%E6%80%BB\">\u5b8c\u6574\u53ef\u8fd0\u884c\u4ee3\u7801\u6c47\u603b<\/h3>\n<p># &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061; \u7b2c\u4e00\u9898 \u6807\u51c6JSON\u5b57\u7b26\u4e32\u8f6clist &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;<br \/>\nimport json<br \/>\nraw_str &#061;&#039;[&#034;qwen-turbo&#034;,&#034;qwen-plus&#034;,&#034;deepseek&#034;]&#039;<br \/>\nmodel_list &#061; json.loads(raw_str)<br \/>\nprint(&#034;\u7b2c\u4e00\u9898\u7ed3\u679c&#xff1a;&#034;, model_list)<\/p>\n<p># &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061; \u7b2c\u4e8c\u9898 \u5b57\u7b26\u4e32\u5316Document&#xff0c;\u6b63\u5219\u63d0\u53d6page\u548c\u5185\u5bb9 &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;<br \/>\nimport re<\/p>\n<p>doc_str &#061; &#034;&#034;&#034;[Document(metadata&#061;{&#039;pk&#039;: 12, &#039;page&#039;: 2}, page_content&#061;&#039;2. \u8d39\u2f64\u62a5\u9500&#xff1a; \u4e1a\u52a1\u6d3b\u52a8\u4e2d\u4ea7\u2f63\u7684\u8d39\u2f64&#xff0c;\u987b\u51ed\u771f \u5b9e\u3001\u5408\u89c4\u7684\u53d1\u7968&#xff0c;\u5e76\u5199\u660e\u4e8b\u7531&#xff0c;\u7ecf\u5ba1\u6279\u540e\u2f45\u53ef\u62a5\u9500\u3002\u4e25\u7981\u865a\u62a5\u3001\\\\\\\\n\u8c0e\u62a5\u8d39\u2f64\u3002\\\\\\\\n\u7b2c\u4e94\u7ae0 \u5956\u60e9\u5236\u5ea6  \\\\\\\\n\u7b2c13\u6761 \u5956\u52b1\\\\\\\\n\u5bf9\u4e8e\u7b26\u5408\u4e0b\u5217\u6761\u4ef6\u7684\u5458\u2f2f&#xff0c;\u516c\u53f8\u5c06\u89c6\u60c5\u51b5\u7ed9\u4e88\u901a\u62a5\u8868\u626c\u3001\u5956\u2fa6\u3001\u664b\u5347\u7b49\u5956\u52b1&#xff1a;\\\\\\\\n1. \u8d85\u989d\u5b8c\u6210\u9500\u552e\u6307\u6807&#xff0c;\u4e1a\u7ee9\u7a81\u51fa\u8005\u3002\\\\\\\\n2. \u63d0\u51fa\u5408\u7406\u5316\u5efa\u8bae&#xff0c;\u7ecf\u91c7\u7eb3\u540e\u4e3a\u516c\u53f8\u5e26\u6765\u663e\u8457\u6548\u76ca\u8005\u3002\\\\\\\\n3. \u5728\u7ef4\u62a4\u516c\u53f8\u5229\u76ca\u548c\u58f0\u8a89\u2f45\u2faf\u6709\u91cd \u2f24\u8d21\u732e\u8005\u3002&#039;), Document(metadata&#061;{&#039;pk&#039;: 27, &#039;page&#039;: 2}, page_content&#061;&#039;2. \u8d39\u2f64\u62a5\u9500&#xff1a; \u4e1a\u52a1\u6d3b\u52a8\u4e2d\u4ea7\u2f63\u7684\u8d39\u2f64&#xff0c;\u987b\u51ed\u771f\u5b9e\u3001\u5408\u89c4\u7684\u53d1\u7968&#xff0c;\u5e76\u5199\u660e\u4e8b\u7531&#xff0c;\u7ecf\u5ba1\u6279\u540e\u2f45\u53ef\u62a5\u9500\u3002\u4e25\u7981\u865a\u62a5\u3001\\\\\\\\n\u8c0e\u62a5\u8d39\u2f64\u3002\\\\\\\\n\u7b2c\u4e94\u7ae0 \u5956\u60e9\u5236\u5ea6  \\\\\\\\n\u7b2c13\u6761 \u5956\u52b1\\\\\\\\n\u5bf9\u4e8e\u7b26\u5408\u4e0b\u5217\u6761\u4ef6\u7684\u5458\u2f2f&#xff0c;\u516c\u53f8\u5c06\u89c6\u60c5\u51b5\u7ed9\u4e88\u901a\u62a5\u8868\u626c\u3001\u5956\u2fa6\u3001\u664b\u5347\u7b49\u5956\u52b1&#xff1a;\\\\\\\\n1. \u8d85\u989d\u5b8c\u6210\u9500\u552e\u6307\u6807&#xff0c;\u4e1a\u7ee9\u7a81\u51fa\u8005\u3002\\\\\\\\n2. \u63d0\u51fa\u5408\u7406\u5316\u5efa\u8bae&#xff0c;\u7ecf\u91c7\u7eb3\u540e\u4e3a\u516c\u53f8\u5e26\u6765\u663e\u8457\u6548\u76ca\u8005\u3002\\\\\\\\n3. \u5728\u7ef4\u62a4\u516c\u53f8\u5229\u76ca\u548c \u58f0\u8a89\u2f45\u2faf\u6709\u91cd\u2f24\u8d21\u732e\u8005\u3002&#039;), Document(metadata&#061;{&#039;pk&#039;: 14, &#039;page&#039;: 3}, page_content&#061;&#039;3. \u6700\u540e\u8b66\u544a&#xff1a; \u60c5\u8282\u4e25\u91cd&#xff0c;\u7559\u53f8\u5bdf\u770b\u3002\\\\\\\\n4. \u2f74\u5373\u89e3\u96c7&#xff1a; \u5bf9\u4e8e\u4e25\u91cd\u8fdd\u7eaa\u8005&#xff0c;\u516c\u53f8\u6709\u6743\u5355\u2f45\u2faf\u2f46\u6761\u4ef6\u89e3\u9664\u52b3\u52a8\u5408\u540c&#xff0c;\u2f46\u9700\u2f40\u4ed8\u7ecf\u6d4e\u8865\u507f\u2fa6\u3002\u4e25\u91cd\u8fdd\u7eaa\u5305\u62ec\u4f46\\\\\\\\n\u4e0d\u9650\u4e8e&#xff1a;\\\\\\\\n\u8d2a\u6c61\u3001\u53d7\u8d3f\u3001\u6cc4\u9732\u6838\u2f3c\u5546\u4e1a\u79d8\u5bc6\u3002\\\\\\\\n\u865a\u62a5\u4e1a\u7ee9\u3001\u4f2a\u9020\u9500\u552e\u8bb0\u5f55\u6216\u62a5\u9500\u51ed\u8bc1\u3002\\\\\\\\n\u2ed3\u671f\u65f7\u2f2f&#xff08;\u8fde\u7eed\u4e09\u5929\u6216\u2f49\u7d2f\u8ba1\u4e94\u5929&#xff09;\u3002\\\\\\\\n\u4e25\u91cd\u5931\u804c&#xff0c;\u7ed9\u516c\u53f8\u9020\u6210\u91cd\u2f24\u7ecf\u6d4e\u635f\u5931\u6216\u58f0\u8a89\u635f\u5bb3\u3002\\\\\\\\n\u8fdd\u53cd\u56fd\u5bb6\u6cd5\u5f8b\u6cd5\u89c4&#xff0c;\u88ab\u4f9d\u6cd5\u8ffd\u7a76\u5211\u4e8b\u8d23\u4efb\u3002\\\\\\\\n\u7b2c\u516d\u7ae0 \u9644\u5219  \\\\\\\\n\u7b2c15\u6761 \u5b88\u5219\u7684\u4fee\u8ba2\u4e0e\u89e3\u91ca&#039;)]&#034;&#034;&#034;<\/p>\n<p>page_pattern &#061; re.compile(r&#034;metadata&#061;\\\\{.*?&#039;page&#039;:\\\\s*(\\\\d&#043;)&#034;)<br \/>\ncontent_pattern &#061; re.compile(r&#034;page_content&#061;&#039;(.*?)&#039;\\\\)&#034;, re.S)<\/p>\n<p>page_nums &#061; [int(x) for x in page_pattern.findall(doc_str)]<br \/>\ncontent_list &#061; content_pattern.findall(doc_str)<br \/>\nconcat_text &#061; &#034;\\\\n&#034;.join(content_list)<\/p>\n<p>print(&#034;\\\\n\u7b2c\u4e8c\u9898\u63d0\u53d6\u9875\u7801&#xff1a;&#034;, page_nums)<br \/>\nprint(&#034;\\\\n\u62fc\u63a5\u540e\u7684\u6587\u6863\u5185\u5bb9&#xff1a;&#034;)<br \/>\nprint(concat_text)<\/p>\n<p># &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061; \u751f\u4ea7\u73af\u5883\u6b63\u786e\u5b58\u50a8Document\u793a\u8303 &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;<br \/>\nfrom langchain_core.documents import Document<\/p>\n<p># \u6a21\u62df\u539f\u59cbdocument\u5bf9\u8c61<br \/>\ndocs &#061; [<br \/>\n    Document(metadata&#061;{&#034;page&#034;:1}, page_content&#061;&#034;\u6587\u68631&#034;),<br \/>\n    Document(metadata&#061;{&#034;page&#034;:2}, page_content&#061;&#034;\u6587\u68632&#034;),<br \/>\n]<br \/>\n# \u5bf9\u8c61\u8f6c\u53ef\u5e8f\u5217\u5316\u5b57\u5178<br \/>\ndump_data &#061; [d.model_dump() for d in docs]<br \/>\njson_text &#061; json.dumps(dump_data, ensure_ascii&#061;False)<br \/>\nprint(&#034;\\\\n\u2705\u751f\u4ea7\u73af\u5883\u5e8f\u5217\u5316\u7ed3\u679c&#xff1a;&#034;, json_text)<br \/>\n# \u6062\u590d<br \/>\nrecover_docs &#061; [Document(**item) for item in json.loads(json_text)]<br \/>\nprint(&#034;\u2705\u6062\u590d\u540e\u7684\u5bf9\u8c61&#xff1a;&#034;, recover_docs)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d \u8a00\u5728\u505a AI \u5e94\u7528\u5f00\u53d1\u65f6&#xff0c;\u6211\u4eec\u7ecf\u5e38\u4f1a\u62ff\u5230\u5404\u79cd \u201c\u770b\u8d77\u6765\u662f\u5bf9\u8c61&#xff0c;\u5b9e\u9645\u662f\u5b57\u7b26\u4e32\u201d \u7684\u6570\u636e&#xff1a;\u914d\u7f6e\u3001\u63a5\u53e3\u8fd4\u56de&#xff1a;[\\&#8221;qwen-turbo\\&#8221;,\\&#8221;qwen-plus\\&#8221;,\\&#8221;deepseek\\&#8221;]&#xff0c;JSON \u683c\u5f0f\u7684\u5b57\u7b26\u4e32\u5217\u8868&#xff1b;\u65e5\u5fd7\u6253\u5370 \/ \u7f13\u5b58\u5b57\u7b26\u4e32&#xff1a;\u628aList[Document]\u76f4\u63a5\u8f6c\u5b57\u7b26\u4e32&#xff0c;\u5f97\u5230\u4e00\u957f\u4e32\\&#8221;[Document(metadata{&#8230;}, page_content.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[99,81,43],"topic":[],"class_list":["post-92643","post","type-post","status-publish","format-standard","hentry","category-server","tag-java","tag-python","tag-43"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Python\uff1a\u5b57\u7b26\u4e32\u4f2a\u88c5\u5217\u8868\u3001\u5b57\u7b26\u4e32\u5e8f\u5217\u5316\u5bf9\u8c61\u89e3\u6790\u8e29\u5751\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/92643.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python\uff1a\u5b57\u7b26\u4e32\u4f2a\u88c5\u5217\u8868\u3001\u5b57\u7b26\u4e32\u5e8f\u5217\u5316\u5bf9\u8c61\u89e3\u6790\u8e29\u5751\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u524d \u8a00\u5728\u505a AI \u5e94\u7528\u5f00\u53d1\u65f6&#xff0c;\u6211\u4eec\u7ecf\u5e38\u4f1a\u62ff\u5230\u5404\u79cd \u201c\u770b\u8d77\u6765\u662f\u5bf9\u8c61&#xff0c;\u5b9e\u9645\u662f\u5b57\u7b26\u4e32\u201d \u7684\u6570\u636e&#xff1a;\u914d\u7f6e\u3001\u63a5\u53e3\u8fd4\u56de&#xff1a;[&quot;qwen-turbo&quot;,&quot;qwen-plus&quot;,&quot;deepseek&quot;]&#xff0c;JSON \u683c\u5f0f\u7684\u5b57\u7b26\u4e32\u5217\u8868&#xff1b;\u65e5\u5fd7\u6253\u5370 \/ \u7f13\u5b58\u5b57\u7b26\u4e32&#xff1a;\u628aList[Document]\u76f4\u63a5\u8f6c\u5b57\u7b26\u4e32&#xff0c;\u5f97\u5230\u4e00\u957f\u4e32&quot;[Document(metadata{...}, page_content.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/92643.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-08-10T12:08:50+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/92643.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/92643.html\",\"name\":\"Python\uff1a\u5b57\u7b26\u4e32\u4f2a\u88c5\u5217\u8868\u3001\u5b57\u7b26\u4e32\u5e8f\u5217\u5316\u5bf9\u8c61\u89e3\u6790\u8e29\u5751\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-08-10T12:08:50+00:00\",\"dateModified\":\"2026-08-10T12:08:50+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/92643.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/92643.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/92643.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python\uff1a\u5b57\u7b26\u4e32\u4f2a\u88c5\u5217\u8868\u3001\u5b57\u7b26\u4e32\u5e8f\u5217\u5316\u5bf9\u8c61\u89e3\u6790\u8e29\u5751\u5b9e\u6218\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python\uff1a\u5b57\u7b26\u4e32\u4f2a\u88c5\u5217\u8868\u3001\u5b57\u7b26\u4e32\u5e8f\u5217\u5316\u5bf9\u8c61\u89e3\u6790\u8e29\u5751\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/92643.html","og_locale":"zh_CN","og_type":"article","og_title":"Python\uff1a\u5b57\u7b26\u4e32\u4f2a\u88c5\u5217\u8868\u3001\u5b57\u7b26\u4e32\u5e8f\u5217\u5316\u5bf9\u8c61\u89e3\u6790\u8e29\u5751\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u524d \u8a00\u5728\u505a AI \u5e94\u7528\u5f00\u53d1\u65f6&#xff0c;\u6211\u4eec\u7ecf\u5e38\u4f1a\u62ff\u5230\u5404\u79cd \u201c\u770b\u8d77\u6765\u662f\u5bf9\u8c61&#xff0c;\u5b9e\u9645\u662f\u5b57\u7b26\u4e32\u201d \u7684\u6570\u636e&#xff1a;\u914d\u7f6e\u3001\u63a5\u53e3\u8fd4\u56de&#xff1a;[\"qwen-turbo\",\"qwen-plus\",\"deepseek\"]&#xff0c;JSON \u683c\u5f0f\u7684\u5b57\u7b26\u4e32\u5217\u8868&#xff1b;\u65e5\u5fd7\u6253\u5370 \/ \u7f13\u5b58\u5b57\u7b26\u4e32&#xff1a;\u628aList[Document]\u76f4\u63a5\u8f6c\u5b57\u7b26\u4e32&#xff0c;\u5f97\u5230\u4e00\u957f\u4e32\"[Document(metadata{...}, page_content.","og_url":"https:\/\/www.wsisp.com\/helps\/92643.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-08-10T12:08:50+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/92643.html","url":"https:\/\/www.wsisp.com\/helps\/92643.html","name":"Python\uff1a\u5b57\u7b26\u4e32\u4f2a\u88c5\u5217\u8868\u3001\u5b57\u7b26\u4e32\u5e8f\u5217\u5316\u5bf9\u8c61\u89e3\u6790\u8e29\u5751\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-08-10T12:08:50+00:00","dateModified":"2026-08-10T12:08:50+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/92643.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/92643.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/92643.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Python\uff1a\u5b57\u7b26\u4e32\u4f2a\u88c5\u5217\u8868\u3001\u5b57\u7b26\u4e32\u5e8f\u5217\u5316\u5bf9\u8c61\u89e3\u6790\u8e29\u5751\u5b9e\u6218"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/92643","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=92643"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/92643\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=92643"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=92643"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=92643"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=92643"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}