{"id":54161,"date":"2025-08-12T23:09:35","date_gmt":"2025-08-12T15:09:35","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/54161.html"},"modified":"2025-08-12T23:09:35","modified_gmt":"2025-08-12T15:09:35","slug":"pydantic%e5%8a%a8%e6%80%81%e7%94%9f%e6%88%90basemodel%e4%bd%9c%e6%95%b0%e6%8d%ae%e9%aa%8c%e8%af%81%e5%b9%b6%e8%87%aa%e5%ae%9a%e4%b9%89%e6%a0%a1%e9%aa%8c%e8%a7%84%e5%88%99","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/54161.html","title":{"rendered":"Pydantic\u52a8\u6001\u751f\u6210BaseModel\u4f5c\u6570\u636e\u9a8c\u8bc1\u5e76\u81ea\u5b9a\u4e49\u6821\u9a8c\u89c4\u5219"},"content":{"rendered":"<h3>\u573a\u666f<\/h3>\n<p>\u5e38\u89c4\u7684\u6570\u636e\u9a8c\u8bc1\u7684\u65b9\u5f0f\u8fd9\u91cc\u5c31\u4e0d\u5728\u8d58\u8ff0\u4e86&#xff0c;\u7f51\u4e0a\u6709\u5f88\u591a\u8d44\u6599\u3002<br \/>\n\u5728\u5b9e\u9645\u4e1a\u52a1\u4e2d&#xff0c;\u6709\u65f6\u5019\u51fa\u51fa\u73b0\u8fd9\u79cd\u60c5\u51b5&#xff0c;\u6bd4\u5982\u6570\u636e\u5e93\u8868\u4e2d\u6709N\u591a\u4e2a\u5b57\u6bb5&#xff0c;\u4e14\u6709M\u5f20\u8868&#xff0c;\u6bcf\u4e2a\u8f93\u5165\u5b57\u6bb5\u90fd\u5bf9\u5e94\u8868\u4e2d\u7684\u4e00\u4e2a\u5b57\u6bb5&#xff0c;\u5e76\u4e14\u524d\u540e\u7aef\u9700\u8981\u4e25\u683c\u6821\u9a8c&#xff0c; \u5982\u679c\u6211\u4eec\u624b\u5199\u8fd9\u6837\u7684basemodel\u65e2\u8d39\u65f6\u8d39\u529b&#xff0c;\u800c\u4e14\u5199\u51fa\u7684\u4ee3\u7801\u81c3\u80bf\u4e14\u4e0d\u6613\u6269\u5c55\u3002<br \/>\n\u6240\u4ee5\u9700\u8981\u80fd\u52a8\u6001\u751f\u6210basemodel&#xff0c;\u8fd9\u6837\u5982\u679c\u8868\u4e2d\u6216\u8005\u914d\u7f6e\u4e2d\u5b57\u6bb5\u6709\u589e\u51cf\u5c31\u4e0d\u9700\u8981\u624b\u52a8\u4fee\u6539basemodel\u7c7b\u4e86\u3002<br \/>\n\u5f3a\u5927\u7684Pydantic\u63d0\u4f9b\u4e86\u8fd9\u4e48\u4e00\u79cd\u673a\u5236\u3002<\/p>\n<p>\u5047\u8bbe\u6709\u8fd9\u79cd\u4e00\u79cd\u573a\u666f&#xff0c;\u4ece\u914d\u7f6e\u6216\u8005\u8868\u4e2d\u83b7\u53d6\u5f85\u9a8c\u8bc1\u7684\u5b57\u6bb5&#xff0c;\u9a8c\u8bc1\u4ece\u524d\u7aef\u8f93\u5165\u7684\u503c\u90fd\u5426\u5728\u67d0\u4e2a\u8303\u56f4&#xff0c;\u4e14\u652f\u6301\u5206\u9875\u67e5\u8be2\u3002 \u67d0\u516c\u53f8\u5458\u5de5\u5e74\u9f84\u89c4\u5b9a\u572820~65\u5c81\u4e4b\u95f4&#xff0c;\u6b63\u5e38\u85aa\u8d44\u8303\u56f45000-50000\/\u6708<br \/>\nage(20~65)<br \/>\nsalary(5000~50000)<\/p>\n<p>\u914d\u7f6e\u5982\u4e0b&#xff1a;<\/p>\n<p>config &#061; {<br \/>\n\u201cage\u201d: {\u201cmin\u201d: 20, \u201cmax\u201d: 65},<br \/>\n\u201csalary\u201d: {\u201cmin\u201d: 5000, \u201cmax\u201d: \u201c50000\u201d}<br \/>\n}<\/p>\n<h3>\u4f2a\u4ee3\u7801\u5b9e\u73b0<\/h3>\n<p><span class=\"token keyword\">from<\/span> pydantic <span class=\"token keyword\">import<\/span> create_model<span class=\"token punctuation\">,<\/span> field_validator<span class=\"token punctuation\">,<\/span> BaseModel<\/p>\n<p><span class=\"token comment\"># \u5206\u9875\u57fa\u672c\u6a21\u578b<\/span><br \/>\n<span class=\"token keyword\">class<\/span> <span class=\"token class-name\">BasePreciseFilterModel<\/span><span class=\"token punctuation\">(<\/span>BaseModel<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    page<span class=\"token punctuation\">:<\/span> <span class=\"token builtin\">int<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">1<\/span><br \/>\n    page_size<span class=\"token punctuation\">:<\/span> <span class=\"token builtin\">int<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">10<\/span><\/p>\n<p><span class=\"token comment\"># \u6821\u9a8c\u51fd\u6570<\/span><br \/>\n<span class=\"token keyword\">def<\/span> <span class=\"token function\">check_min_max_value<\/span><span class=\"token punctuation\">(<\/span>key<span class=\"token punctuation\">)<\/span><\/p>\n<p>baseline_min_value <span class=\"token operator\">&#061;<\/span> config<span class=\"token punctuation\">[<\/span>key<span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">[<\/span><span class=\"token string\">&#034;min&#034;<\/span><span class=\"token punctuation\">]<\/span><br \/>\nbaseline_max_value <span class=\"token operator\">&#061;<\/span> coofig<span class=\"token punctuation\">[<\/span>key<span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">[<\/span><span class=\"token string\">&#034;max&#034;<\/span><span class=\"token punctuation\">]<\/span><\/p>\n<p><span class=\"token comment\"># \u8fd9\u8fb9\u5176\u5b9e\u7528\u4e86\u4e00\u4e2a\u95ed\u5305&#xff0c;\u7528\u4e8e\u4f20\u5165\u914d\u7f6e\u4e2d\u7684key&#xff0c;\u5e76\u548c\u8fd9\u91cc v \u4e2d\u4f20\u5165\u7684\u524d\u7aef\u8f93\u5165\u53c2\u6570\u4e2d\u7684\u53ea\u505a\u6821\u9a8c<\/span><br \/>\n<span class=\"token keyword\">def<\/span> <span class=\"token function\">_check_min_max_value<\/span><span class=\"token punctuation\">(<\/span>cls<span class=\"token punctuation\">,<\/span> v<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n_min_value_input <span class=\"token operator\">&#061;<\/span> v<span class=\"token punctuation\">.<\/span>get<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;min&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\n_max_value_input <span class=\"token operator\">&#061;<\/span> v<span class=\"token punctuation\">.<\/span>get<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;max&#034;<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token keyword\">if<\/span> _min_value_input <span class=\"token operator\">&lt;<\/span> baseline_min_value<span class=\"token punctuation\">:<\/span><br \/>\n<span class=\"token keyword\">raise<\/span> ValueError<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token keyword\">if<\/span> _max_value_input <span class=\"token operator\">&gt;<\/span> baseline_max_value<span class=\"token punctuation\">:<\/span><br \/>\n<span class=\"token keyword\">raise<\/span> ValueError<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token keyword\">return<\/span> v<br \/>\n<span class=\"token keyword\">return<\/span> _check_min_max_value<\/p>\n<p><span class=\"token comment\"># \u751f\u6210\u6bcf\u4e2a\u5c5e\u6027\u7684\u6821\u9a8c\u5668, \u8fd9\u91cc\u7684 field_validator \u5b9e\u9645\u662f\u4e00\u4e2a\u7c7b\u88c5\u9970\u5668<\/span><br \/>\nvalidators <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token string-interpolation\"><span class=\"token string\">f&#034;<\/span><span class=\"token interpolation\"><span class=\"token punctuation\">{<\/span>key<span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">_validator&#034;<\/span><\/span><span class=\"token punctuation\">:<\/span> field_validator<span class=\"token punctuation\">(<\/span>key<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">(<\/span>check_min_max_value<span class=\"token punctuation\">(<\/span>key<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token keyword\">for<\/span> key <span class=\"token keyword\">in<\/span> config<span class=\"token punctuation\">.<\/span>keys<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token comment\"># \u52a8\u6001\u751f\u6210\u7684\u6700\u7ec8Model\u7c7b<\/span><br \/>\nPreciseSearchFilterModel <span class=\"token operator\">&#061;<\/span> create_model<span class=\"token punctuation\">(<\/span><br \/>\n    <span class=\"token string\">&#034;PreciseSearchFilterModel &#034;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token operator\">**<\/span><span class=\"token punctuation\">{<\/span>key<span class=\"token punctuation\">:<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token builtin\">dict<\/span> <span class=\"token operator\">|<\/span> <span class=\"token boolean\">None<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token boolean\">None<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">for<\/span> key <span class=\"token keyword\">in<\/span> config<span class=\"token punctuation\">.<\/span>keys<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    __validators__<span class=\"token operator\">&#061;<\/span>validators<span class=\"token punctuation\">,<\/span><br \/>\n    __base__<span class=\"token operator\">&#061;<\/span>BasePreciseFilterModel<br \/>\n<span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token comment\"># \u63a5\u4e0b\u6765\u5c31\u53ef\u4ee5\u5e94\u7528\u8fd9\u4e2aModel\u7c7b\u9a8c\u8bc1\u8f93\u5165\u4e86&#xff0c; \u6bd4\u5982\u5728\u6211\u4eec\u7684 Django\u3001Flask\u3001FastApi\u7b49\u9879\u76ee\u4e2d\u3002<\/span><br \/>\n<span class=\"token comment\"># \u524d\u7aef\u4f20\u5165\u7684payload\u5982\u4e0b, \u641c\u7d22\u5e74\u9f84\u5728 25~60\u5c81\u4e4b\u95f4&#xff0c;\u4e14\u85aa\u8d44\u572810000~20000\u533a\u95f4\u7684\u5458\u5de5<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><span class=\"token string\">&#034;age&#034;<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token punctuation\">{<\/span><span class=\"token string\">&#034;min&#034;<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token number\">25<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;max&#034;<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token number\">60<\/span><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;salary&#034;<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token punctuation\">{<\/span><span class=\"token string\">&#034;min&#034;<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token number\">10000<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;max&#034;<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token number\">20000<\/span><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;page&#034;<\/span><span class=\"token punctuation\">:<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;page_size&#034;<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token number\">5<\/span><span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token decorator annotation punctuation\">&#064;app<span class=\"token punctuation\">.<\/span>route<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;filter&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token keyword\">def<\/span> <span class=\"token function\">precise_filter<\/span><span class=\"token punctuation\">(<\/span><span class=\"token builtin\">filter<\/span><span class=\"token punctuation\">:<\/span> PreciseSearchFilterModel<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><\/p>\n<p>filter_params <span class=\"token operator\">&#061;<\/span> <span class=\"token builtin\">filter<\/span><span class=\"token punctuation\">.<\/span>model_dump<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    page <span class=\"token operator\">&#061;<\/span> filter_params<span class=\"token punctuation\">.<\/span>pop<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;page&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    page_size <span class=\"token operator\">&#061;<\/span> filter_params<span class=\"token punctuation\">.<\/span>pop<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;page_size&#034;<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token comment\"># TODO \u4e1a\u52a1\u903b\u8f91<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb48\u6b21\u3002\u3010\u4ee3\u7801\u3011\u52a8\u6001\u751f\u6210BaseModel\u6570\u636e\u9a8c\u8bc1\u5e76\u81ea\u5b9a\u4e49\u6821\u9a8c\u89c4\u5219\u3002<\/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":[81,3944],"topic":[],"class_list":["post-54161","post","type-post","status-publish","format-standard","hentry","category-server","tag-python","tag-3944"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Pydantic\u52a8\u6001\u751f\u6210BaseModel\u4f5c\u6570\u636e\u9a8c\u8bc1\u5e76\u81ea\u5b9a\u4e49\u6821\u9a8c\u89c4\u5219 - \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\/54161.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Pydantic\u52a8\u6001\u751f\u6210BaseModel\u4f5c\u6570\u636e\u9a8c\u8bc1\u5e76\u81ea\u5b9a\u4e49\u6821\u9a8c\u89c4\u5219 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb48\u6b21\u3002\u3010\u4ee3\u7801\u3011\u52a8\u6001\u751f\u6210BaseModel\u6570\u636e\u9a8c\u8bc1\u5e76\u81ea\u5b9a\u4e49\u6821\u9a8c\u89c4\u5219\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/54161.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-08-12T15:09:35+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=\"1 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/54161.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/54161.html\",\"name\":\"Pydantic\u52a8\u6001\u751f\u6210BaseModel\u4f5c\u6570\u636e\u9a8c\u8bc1\u5e76\u81ea\u5b9a\u4e49\u6821\u9a8c\u89c4\u5219 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-08-12T15:09:35+00:00\",\"dateModified\":\"2025-08-12T15:09:35+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/54161.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/54161.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/54161.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Pydantic\u52a8\u6001\u751f\u6210BaseModel\u4f5c\u6570\u636e\u9a8c\u8bc1\u5e76\u81ea\u5b9a\u4e49\u6821\u9a8c\u89c4\u5219\"}]},{\"@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":"Pydantic\u52a8\u6001\u751f\u6210BaseModel\u4f5c\u6570\u636e\u9a8c\u8bc1\u5e76\u81ea\u5b9a\u4e49\u6821\u9a8c\u89c4\u5219 - \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\/54161.html","og_locale":"zh_CN","og_type":"article","og_title":"Pydantic\u52a8\u6001\u751f\u6210BaseModel\u4f5c\u6570\u636e\u9a8c\u8bc1\u5e76\u81ea\u5b9a\u4e49\u6821\u9a8c\u89c4\u5219 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb48\u6b21\u3002\u3010\u4ee3\u7801\u3011\u52a8\u6001\u751f\u6210BaseModel\u6570\u636e\u9a8c\u8bc1\u5e76\u81ea\u5b9a\u4e49\u6821\u9a8c\u89c4\u5219\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/54161.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-08-12T15:09:35+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/54161.html","url":"https:\/\/www.wsisp.com\/helps\/54161.html","name":"Pydantic\u52a8\u6001\u751f\u6210BaseModel\u4f5c\u6570\u636e\u9a8c\u8bc1\u5e76\u81ea\u5b9a\u4e49\u6821\u9a8c\u89c4\u5219 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-08-12T15:09:35+00:00","dateModified":"2025-08-12T15:09:35+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/54161.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/54161.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/54161.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Pydantic\u52a8\u6001\u751f\u6210BaseModel\u4f5c\u6570\u636e\u9a8c\u8bc1\u5e76\u81ea\u5b9a\u4e49\u6821\u9a8c\u89c4\u5219"}]},{"@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\/54161","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=54161"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/54161\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=54161"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=54161"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=54161"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=54161"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}