{"id":67645,"date":"2021-05-09T19:55:35","date_gmt":"2021-05-09T11:55:35","guid":{"rendered":"http:\/\/www.zhushiyao.com\/?p=67645"},"modified":"2021-05-09T19:56:38","modified_gmt":"2021-05-09T11:56:38","slug":"d1568b0a3e","status":"publish","type":"post","link":"http:\/\/www.zhushiyao.com\/?p=67645","title":{"rendered":"marshmallow\uff0c\u652f\u6301 Python \u5bf9\u8c61\u548c\u539f\u751f\u6570\u636e\u76f8\u4e92\u8f6c\u6362\u7684\u5e93"},"content":{"rendered":"<div class=\"bpp-post-content\">\n<p style=\"margin-right: 16px; margin-left: 16px; max-width: 100%; min-height: 1em; font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif; letter-spacing: 0.544px; white-space: normal; background-color: #ffffff; text-align: left; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><span style=\"max-width: 100%; font-size: 14px; letter-spacing: 0.2em; word-spacing: 0.1em; color: black; font-family: PingFangSC-Light; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u5728\u5f88\u591a\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u4f1a\u6709\u628a Python \u5bf9\u8c61\u8fdb\u884c\u5e8f\u5217\u5316\u6216\u53cd\u5e8f\u5217\u5316\u7684\u9700\u6c42\uff0c\u6bd4\u5982\u5f00\u53d1 REST API\uff0c\u6bd4\u5982\u4e00\u4e9b\u9762\u5411\u5bf9\u8c61\u5316\u7684\u6570\u636e\u52a0\u8f7d\u548c\u4fdd\u5b58\uff0c\u90fd\u4f1a\u5e94\u7528\u5230\u8fd9\u4e2a\u529f\u80fd\u3002<\/span><\/p>\n<section style=\"padding: 10px; max-width: 100%; overflow-wrap: break-word; white-space: normal; background-color: #ffffff; font-size: 16px; color: black; line-height: 1.6; letter-spacing: 0px; word-break: break-word; text-align: left; font-family: PingFangSC-Light; box-sizing: border-box !important;\">\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u8fd9\u91cc\u770b\u4e00\u4e2a\u6700\u57fa\u672c\u7684\u4f8b\u5b50\uff0c\u8fd9\u91cc\u7ed9\u5230\u4e00\u4e2a User \u7684 Class \u5b9a\u4e49\uff0c\u518d\u7ed9\u5230\u4e00\u4e2a data \u6570\u636e\uff0c\u50cf\u8fd9\u6837\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><code style=\"padding: 16px; max-width: 100%; overflow-x: auto; background: #272822; color: #dddddd; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; border-radius: 0px; font-size: 12px; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">class<\/span> <span style=\"max-width: 100%; font-weight: bold; color: white; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">User<\/span><span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">(object)<\/span>:<\/span><br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    <span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">def<\/span> <span style=\"max-width: 100%; color: #a6e22e; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">__init__<\/span><span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">(self, name, age)<\/span>:<\/span><br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>        self.name = name<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>        self.age = age<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>data = [{<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    <span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'name'<\/span>: <span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'Germey'<\/span>,<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    <span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'age'<\/span>: <span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">23<\/span><br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>}, {<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    <span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'name'<\/span>: <span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'Mike'<\/span>,<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    <span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'age'<\/span>: <span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">20<\/span><br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>}]<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><\/code><\/pre>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u73b0\u5728\u6211\u8981\u628a\u8fd9\u4e2a data \u5feb\u901f\u8f6c\u6210 User \u7ec4\u6210\u7684\u6570\u7ec4\uff0c\u53d8\u6210\u8fd9\u6837\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><code style=\"padding: 16px; max-width: 100%; overflow-x: auto; background: #272822; color: #dddddd; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; border-radius: 0px; font-size: 12px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">[User(name=<span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'Germey'<\/span>, age=<span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">23<\/span>), User(name=<span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'Mike'<\/span>, age=<span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">20<\/span>)]<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><\/code><\/pre>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u4f60\u4f1a\u600e\u4e48\u6765\u5b9e\u73b0\uff1f<\/p>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u6216\u8005\u6211\u6709\u4e86\u4e0a\u9762\u7684\u5217\u8868\u5185\u5bb9\uff0c\u60f3\u8981\u8f6c\u6210\u4e00\u4e2a JSON \u5b57\u7b26\u4e32\uff0c\u53d8\u6210\u8fd9\u6837\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><code style=\"padding: 16px; max-width: 100%; overflow-x: auto; background: #272822; color: #dddddd; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; border-radius: 0px; font-size: 12px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">[{<span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\"name\"<\/span>: <span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\"Germey\"<\/span>, <span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\"age\"<\/span>: <span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">23<\/span>}, {<span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\"name\"<\/span>: <span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\"Mike\"<\/span>, <span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\"age\"<\/span>: <span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">20<\/span>}]<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><\/code><\/pre>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u4f60\u53c8\u4f1a\u600e\u4e48\u64cd\u4f5c\u5462\uff1f<\/p>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u53e6\u5916\u5982\u679c JSON \u6570\u636e\u91cc\u9762\u6709\u5404\u79cd\u5404\u6837\u7684\u810f\u6570\u636e\uff0c\u4f60\u9700\u8981\u5728\u521d\u59cb\u5316\u65f6\u9a8c\u8bc1\u8fd9\u4e9b\u5b57\u6bb5\u662f\u5426\u5408\u6cd5\uff0c\u53e6\u5916 User \u8fd9\u4e2a\u5bf9\u8c61\u91cc\u9762 name\u3001age \u7684\u6570\u636e\u7c7b\u578b\u4e0d\u540c\uff0c\u5982\u4f55\u9488\u5bf9\u4e0d\u540c\u7684\u6570\u636e\u7c7b\u578b\u8fdb\u884c\u9488\u5bf9\u6027\u7684\u7c7b\u578b\u8f6c\u6362\uff0c\u8fd9\u4e2a\u4f60\u6709\u66f4\u597d\u7684\u5b9e\u73b0\u65b9\u6848\u5417\uff1f<\/p>\n<h2 style=\"margin-top: 20px; margin-right: 10px; font-weight: bold; font-size: 24px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><span style=\"padding-left: 10px; max-width: 100%; font-family: STHeitiSC-Light; font-size: 18px; font-weight: bolder; display: inline-block; border-left: 5px solid #f83929; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u521d\u6b65\u601d\u8def<\/span><\/h2>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u4e4b\u524d\u6211\u4ecb\u7ecd\u8fc7 attrs \u548c cattrs \u8fd9\u4e24\u4e2a\u5e93\uff0c\u5b83\u4eec\u4e8c\u8005\u7684\u7ec4\u5408\u53ef\u4ee5\u975e\u5e38\u65b9\u4fbf\u5730\u5b9e\u73b0\u5bf9\u8c61\u7684\u5e8f\u5217\u5316\u548c\u53cd\u5e8f\u5217\u5316\u3002<\/p>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u8b6c\u5982\u8fd9\u6837\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><code style=\"padding: 16px; max-width: 100%; overflow-x: auto; background: #272822; color: #dddddd; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; border-radius: 0px; font-size: 12px; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">from<\/span> attr <span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">import<\/span> attrs, attrib<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">from<\/span> cattr <span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">import<\/span> structure, unstructure<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><span style=\"max-width: 100%; color: #75715e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">@attrs<\/span><br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">class<\/span> <span style=\"max-width: 100%; font-weight: bold; color: white; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">User<\/span><span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">(object)<\/span>:<\/span><br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    name = attrib()<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    age = attrib()<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>data = {<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    <span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'name'<\/span>: <span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'Germey'<\/span>,<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    <span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'age'<\/span>: <span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">23<\/span><br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>}<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>user = structure(data, User)<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>print(<span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'user'<\/span>, user)<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>json = unstructure(user)<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>print(<span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'json'<\/span>, json)<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><\/code><\/pre>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u8fd0\u884c\u7ed3\u679c\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><code style=\"padding: 16px; max-width: 100%; overflow-x: auto; background: #272822; color: #dddddd; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; border-radius: 0px; font-size: 12px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">user User(name=<span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'Germey'<\/span>, age=<span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">23<\/span>)<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>json {<span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'name'<\/span>: <span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'Germey'<\/span>, <span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'age'<\/span>: <span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">23<\/span>}<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><\/code><\/pre>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u597d\uff0c\u8fd9\u91cc\u6211\u4eec\u901a\u8fc7 attrs \u548c cattrs \u8fd9\u4e24\u4e2a\u5e93\u6765\u5b9e\u73b0\u4e86\u5355\u4e2a\u5bf9\u8c61\u7684\u8f6c\u6362\u3002<\/p>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u9996\u5148\u6211\u4eec\u8981\u80af\u5b9a\u4e00\u4e0b attrs \u8fd9\u4e2a\u5e93\uff0c\u5b83\u53ef\u4ee5\u6781\u5927\u5730\u7b80\u5316 Python \u7c7b\u7684\u5b9a\u4e49\uff0c\u540c\u65f6\u6bcf\u4e2a\u5b57\u6bb5\u53ef\u4ee5\u5b9a\u4e49\u591a\u79cd\u6570\u636e\u7c7b\u578b\u3002<\/p>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u4f46 cattrs \u8fd9\u4e2a\u5e93\u5c31\u76f8\u5bf9\u5f31\u4e00\u4e9b\u4e86\uff0c\u5982\u679c\u628a data \u6362\u6210\u6570\u7ec4\uff0c\u7528 cattrs \u8fd8\u662f\u4e0d\u600e\u4e48\u597d\u8f6c\u6362\u7684\uff0c\u53e6\u5916\u5b83\u7684 structure \u548c unstructure \u5728\u67d0\u4e9b\u60c5\u666f\u4e0b\u5bb9\u9519\u80fd\u529b\u8f83\u5dee\uff0c\u6240\u4ee5\u5bf9\u4e8e\u4e0a\u9762\u7684\u9700\u6c42\uff0c\u7528\u8fd9\u4e24\u4e2a\u5e93\u642d\u914d\u8d77\u6765\u5e76\u4e0d\u662f\u4e00\u4e2a\u6700\u4f18\u7684\u89e3\u51b3\u65b9\u6848\u3002<\/p>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u53e6\u5916\u6570\u636e\u7684\u6821\u9a8c\u4e5f\u662f\u4e00\u4e2a\u95ee\u9898\uff0cattrs \u867d\u7136\u63d0\u4f9b\u4e86 validator \u7684\u53c2\u6570\uff0c\u4f46\u5bf9\u4e8e\u591a\u79cd\u7c7b\u578b\u7684\u6570\u636e\u5904\u7406\u7684\u652f\u6301\u5e76\u6ca1\u6709\u90a3\u4e48\u5f3a\u5927\u3002<\/p>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u6240\u4ee5\uff0c\u6211\u4eec\u60f3\u8981\u5bfb\u6c42\u4e00\u4e2a\u66f4\u4f18\u7684\u89e3\u51b3\u65b9\u6848\u3002<\/p>\n<h2 style=\"margin-top: 20px; margin-right: 10px; font-weight: bold; font-size: 24px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><span style=\"padding-left: 10px; max-width: 100%; font-family: STHeitiSC-Light; font-size: 18px; font-weight: bolder; display: inline-block; border-left: 5px solid #f83929; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u66f4\u4f18\u96c5\u7684\u65b9\u6848<\/span><\/h2>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u8fd9\u91cc\u63a8\u8350\u4e00\u4e2a\u5e93\uff0c\u53eb\u505a marshmallow\uff0c\u5b83\u662f\u4e13\u95e8\u7528\u6765\u652f\u6301 Python \u5bf9\u8c61\u548c\u539f\u751f\u6570\u636e\u76f8\u4e92\u8f6c\u6362\u7684\u5e93\uff0c\u5982\u5b9e\u73b0 object -&gt; dict\uff0cobjects -&gt; list, string -&gt; dict, string -&gt; list \u7b49\u7684\u8f6c\u6362\u529f\u80fd\uff0c\u53e6\u5916\u5b83\u8fd8\u63d0\u4f9b\u4e86\u975e\u5e38\u4e30\u5bcc\u7684\u6570\u636e\u7c7b\u578b\u8f6c\u6362\u548c\u6821\u9a8c API\uff0c\u5e2e\u52a9\u6211\u4eec\u5feb\u901f\u5b9e\u73b0\u6570\u636e\u7684\u8f6c\u6362\u3002<\/p>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u8981\u4f7f\u7528 marshmallow \u8fd9\u4e2a\u5e93\uff0c\u9700\u8981\u5148\u5b89\u88c5\u4e0b\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><code style=\"padding: 16px; max-width: 100%; overflow-x: auto; background: #272822; color: #dddddd; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; border-radius: 0px; font-size: 12px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">pip3 install marshmallow<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><\/code><\/pre>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u597d\u4e86\u4e4b\u540e\uff0c\u6211\u4eec\u5728\u4e4b\u524d\u7684\u57fa\u7840\u4e0a\u5b9a\u4e49\u4e00\u4e2a Schema\uff0c\u5982\u4e0b\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><code style=\"padding: 16px; max-width: 100%; overflow-x: auto; background: #272822; color: #dddddd; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; border-radius: 0px; font-size: 12px; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">class<\/span> <span style=\"max-width: 100%; font-weight: bold; color: white; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">UserSchema<\/span><span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">(Schema)<\/span>:<\/span><br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    name = fields.Str()<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    age = fields.Integer()<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    <br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><span style=\"max-width: 100%; color: #75715e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">    @post_load<\/span><br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    <span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">def<\/span> <span style=\"max-width: 100%; color: #a6e22e; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">make<\/span><span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">(self, data, **kwargs)<\/span>:<\/span><br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>        <span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">return<\/span> User(**data)<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><\/code><\/pre>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u8fd8\u662f\u4e4b\u524d\u7684\u6570\u636e\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><code style=\"padding: 16px; max-width: 100%; overflow-x: auto; background: #272822; color: #dddddd; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; border-radius: 0px; font-size: 12px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">data = [{<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    <span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'name'<\/span>: <span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'Germey'<\/span>,<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    <span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'age'<\/span>: <span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">23<\/span><br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>}, {<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    <span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'name'<\/span>: <span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'Mike'<\/span>,<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    <span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'age'<\/span>: <span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">20<\/span><br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>}]<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><\/code><\/pre>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u8fd9\u65f6\u5019\u6211\u4eec\u53ea\u9700\u8981\u8c03\u7528 Schema \u7684 load \u4e8b\u4ef6\u5c31\u597d\u4e86\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><code style=\"padding: 16px; max-width: 100%; overflow-x: auto; background: #272822; color: #dddddd; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; border-radius: 0px; font-size: 12px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">schema = UserSchema()<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>users = schema.load(data, many=<span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">True<\/span>)<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>print(users)<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><\/code><\/pre>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><code style=\"padding: 16px; max-width: 100%; overflow-x: auto; background: #272822; color: #dddddd; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; border-radius: 0px; font-size: 12px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">[User(name=<span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'Germey'<\/span>, age=<span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">23<\/span>), User(name=<span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'Mike'<\/span>, age=<span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">20<\/span>)]<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><\/code><\/pre>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u8fd9\u6837\uff0c\u6211\u4eec\u975e\u5e38\u8f7b\u677e\u5730\u5b8c\u6210\u4e86 JSON \u5230 User List \u7684\u8f6c\u6362\u3002<\/p>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u6709\u4eba\u8bf4\uff0c\u5982\u679c\u662f\u5355\u4e2a\u6570\u636e\u600e\u4e48\u529e\u5462\uff0c\u53ea\u9700\u8981\u628a load \u65b9\u6cd5\u7684 many \u53c2\u6570\u53bb\u6389\u5373\u53ef\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><code style=\"padding: 16px; max-width: 100%; overflow-x: auto; background: #272822; color: #dddddd; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; border-radius: 0px; font-size: 12px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">data = {<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    <span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'name'<\/span>: <span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'Germey'<\/span>,<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    <span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'age'<\/span>: <span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">23<\/span><br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>}<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>schema = UserSchema()<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>user = schema.load(data)<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>print(user)<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><\/code><\/pre>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u8f93\u51fa\u7ed3\u679c\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><code style=\"padding: 16px; max-width: 100%; overflow-x: auto; background: #272822; color: #dddddd; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; border-radius: 0px; font-size: 12px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">User(name=<span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'Germey'<\/span>, age=<span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">23<\/span>)<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><\/code><\/pre>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u5f53\u7136\uff0c\u8fd9\u4ec5\u4ec5\u662f\u4e00\u4e2a\u53cd\u5e8f\u5217\u5316\u64cd\u4f5c\uff0c\u6211\u4eec\u8fd8\u53ef\u4ee5\u6b63\u5411\u8fdb\u884c\u5e8f\u5217\u5316\uff0c\u4ee5\u53ca\u4f7f\u7528\u5404\u79cd\u5404\u6837\u7684\u9a8c\u8bc1\u6761\u4ef6\u3002<\/p>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u4e0b\u9762\u6211\u4eec\u518d\u6765\u770b\u770b\u5427\u3002<\/p>\n<h2 style=\"margin-top: 20px; margin-right: 10px; font-weight: bold; font-size: 24px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><span style=\"padding-left: 10px; max-width: 100%; font-family: STHeitiSC-Light; font-size: 18px; font-weight: bolder; display: inline-block; border-left: 5px solid #f83929; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u66f4\u65b9\u4fbf\u7684\u5e8f\u5217\u5316<\/span><\/h2>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u4e0a\u9762\u7684\u4f8b\u5b50\u6211\u4eec\u5b9e\u73b0\u4e86\u5e8f\u5217\u5316\u64cd\u4f5c\uff0c\u8f93\u51fa\u4e86 users \u4e3a\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><code style=\"padding: 16px; max-width: 100%; overflow-x: auto; background: #272822; color: #dddddd; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; border-radius: 0px; font-size: 12px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">[User(name=<span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'Germey'<\/span>, age=<span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">23<\/span>), User(name=<span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'Mike'<\/span>, age=<span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">20<\/span>)]<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><\/code><\/pre>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u6709\u4e86\u8fd9\u4e2a\u6570\u636e\uff0c\u6211\u4eec\u4e5f\u80fd\u8f7b\u677e\u5b9e\u73b0\u5e8f\u5217\u5316\u64cd\u4f5c\u3002<\/p>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u5e8f\u5217\u5316\u64cd\u4f5c\uff0c\u4f7f\u7528 dump \u65b9\u6cd5\u5373\u53ef<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><code style=\"padding: 16px; max-width: 100%; overflow-x: auto; background: #272822; color: #dddddd; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; border-radius: 0px; font-size: 12px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">result = schema.dump(users, many=<span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">True<\/span>)<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>print(<span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'result'<\/span>, result)<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><\/code><\/pre>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u8fd0\u884c\u7ed3\u679c\u5982\u4e0b\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><code style=\"padding: 16px; max-width: 100%; overflow-x: auto; background: #272822; color: #dddddd; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; border-radius: 0px; font-size: 12px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">result [{'age': 23, 'name': 'Germey'}, {'age': 20, 'name': 'Mike'}]<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><\/code><\/pre>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u7531\u4e8e\u662f List\uff0c\u6240\u4ee5 dump \u65b9\u6cd5\u9700\u8981\u52a0\u4e00\u4e2a\u53c2\u6570 many \u4e3a True\u3002<\/p>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u5f53\u7136\u5bf9\u4e8e\u5355\u4e2a\u5bf9\u8c61\uff0c\u76f4\u63a5\u4f7f\u7528 dump \u540c\u6837\u662f\u53ef\u4ee5\u7684\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><code style=\"padding: 16px; max-width: 100%; overflow-x: auto; background: #272822; color: #dddddd; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; border-radius: 0px; font-size: 12px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">result = schema.dump(user)<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>print(<span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'result'<\/span>, result)<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><\/code><\/pre>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u8fd0\u884c\u7ed3\u679c\u5982\u4e0b\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><code style=\"padding: 16px; max-width: 100%; overflow-x: auto; background: #272822; color: #dddddd; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; border-radius: 0px; font-size: 12px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">result {<span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'name'<\/span>: <span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'Germey'<\/span>, <span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'age'<\/span>: <span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">23<\/span>}<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><\/code><\/pre>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u8fd9\u6837\u7684\u8bdd\uff0c\u5355\u4e2a\u3001\u591a\u4e2a\u5bf9\u8c61\u7684\u5e8f\u5217\u5316\u4e5f\u4e0d\u518d\u662f\u96be\u4e8b\u3002<\/p>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u7ecf\u8fc7\u4e0a\u9762\u7684\u64cd\u4f5c\uff0c\u6211\u4eec\u5b8c\u6210\u4e86 object \u5230 dict \u6216 list \u7684\u8f6c\u6362\uff0c\u5373\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><code style=\"padding: 16px; max-width: 100%; overflow-x: auto; background: #272822; color: #dddddd; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; border-radius: 0px; font-size: 12px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">object &lt;-&gt; dict<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>objects &lt;-&gt; list<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><\/code><\/pre>\n<h2 style=\"margin-top: 20px; margin-right: 10px; font-weight: bold; font-size: 24px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><span style=\"padding-left: 10px; max-width: 100%; font-family: STHeitiSC-Light; font-size: 18px; font-weight: bolder; display: inline-block; border-left: 5px solid #f83929; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u9a8c\u8bc1<\/span><\/h2>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u5f53\u7136\uff0c\u4e0a\u9762\u7684\u529f\u80fd\u5176\u5b9e\u5e76\u4e0d\u8db3\u4ee5\u8ba9\u4f60\u89c9\u5f97 marshmallow \u6709\u591a\u4e48\u4e86\u4e0d\u8d77\uff0c\u5176\u5b9e\u5c31\u662f\u4e00\u4e2a\u5bf9\u8c61\u5230\u57fa\u672c\u6570\u636e\u7684\u8f6c\u6362\u561b\u3002\u4f46\u80af\u5b9a\u4e0d\u6b62\u8fd9\u4e9b\uff0cmarshmallow \u8fd8\u63d0\u4f9b\u4e86\u66f4\u52a0\u5f3a\u5927\u554a\u529f\u80fd\uff0c\u6bd4\u5982\u8bf4\u9a8c\u8bc1\uff0cValidation\u3002<\/p>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u6bd4\u5982\u8fd9\u91cc\u6211\u4eec\u5c06 age \u8fd9\u4e2a\u5b57\u6bb5\u8bbe\u7f6e\u4e3a hello\uff0c\u5b83\u65e0\u6cd5\u88ab\u8f6c\u6362\u6210\u6570\u503c\u7c7b\u578b\uff0c\u6240\u4ee5\u80af\u5b9a\u4f1a\u62a5\u9519\uff0c\u6837\u4f8b\u5982\u4e0b\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><code style=\"padding: 16px; max-width: 100%; overflow-x: auto; background: #272822; color: #dddddd; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; border-radius: 0px; font-size: 12px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">data = {<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    <span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'name'<\/span>: <span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'Germey'<\/span>,<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    <span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'age'<\/span>: <span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'hello'<\/span><br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>}<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">from<\/span> marshmallow <span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">import<\/span> ValidationError<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">try<\/span>:<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    schema = UserSchema()<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    user, errors = schema.load(data)<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    print(user, errors)<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">except<\/span> ValidationError <span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">as<\/span> e:<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    print(<span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'e.message'<\/span>, e.messages)<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    print(<span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'e.valid_data'<\/span>, e.valid_data)<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><\/code><\/pre>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u8fd9\u91cc\u5982\u679c\u52a0\u8f7d\u62a5\u9519\uff0c\u6211\u4eec\u53ef\u4ee5\u76f4\u63a5\u62ff\u5230 Error \u7684 messages \u548c valid_data \u5bf9\u8c61\uff0c\u5b83\u5305\u542b\u4e86\u9519\u8bef\u7684\u4fe1\u606f\u548c\u6b63\u786e\u7684\u5b57\u6bb5\u7ed3\u679c\uff0c\u8fd0\u884c\u7ed3\u679c\u5982\u4e0b\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><code style=\"padding: 16px; max-width: 100%; overflow-x: auto; background: #272822; color: #dddddd; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; border-radius: 0px; font-size: 12px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">e.message {<span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'age'<\/span>: [<span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'Not a valid integer.'<\/span>]}<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>e.valid_data {<span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'name'<\/span>: <span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'Germey'<\/span>}<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><\/code><\/pre>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u56e0\u6b64\uff0c\u6bd4\u5982\u6211\u4eec\u60f3\u8981\u5f00\u53d1\u4e00\u4e2a\u529f\u80fd\uff0c\u6bd4\u5982\u7528\u6237\u6ce8\u518c\uff0c\u8868\u5355\u4fe1\u606f\u5c31\u662f\u63d0\u4ea4\u8fc7\u6765\u7684 data\uff0c\u6211\u4eec\u53ea\u9700\u8981\u8fc7\u4e00\u904d Validation\uff0c\u5c31\u53ef\u4ee5\u8f7b\u677e\u5f97\u77e5\u54ea\u4e9b\u6570\u636e\u7b26\u5408\u8981\u6c42\uff0c\u54ea\u4e9b\u4e0d\u7b26\u5408\u8981\u6c42\uff0c\u63a5\u7740\u518d\u8fdb\u4e00\u6b65\u8fdb\u884c\u5904\u7406\u3002<\/p>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u5f53\u7136\u9a8c\u8bc1\u529f\u80fd\u80af\u5b9a\u4e0d\u6b62\u8fd9\u4e00\u4e9b\uff0c\u6211\u4eec\u518d\u6765\u611f\u53d7\u4e00\u4e0b\u53e6\u4e00\u4e2a\u793a\u4f8b\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><code style=\"padding: 16px; max-width: 100%; overflow-x: auto; background: #272822; color: #dddddd; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; border-radius: 0px; font-size: 12px; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">from<\/span> pprint <span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">import<\/span> pprint<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">from<\/span> marshmallow <span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">import<\/span> Schema, fields, validate, ValidationError<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">class<\/span> <span style=\"max-width: 100%; font-weight: bold; color: white; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">UserSchema<\/span><span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">(Schema)<\/span>:<\/span><br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    name = fields.Str(validate=validate.Length(min=<span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">1<\/span>))<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    permission = fields.Str(validate=validate.OneOf([<span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'read'<\/span>, <span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'write'<\/span>, <span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'admin'<\/span>]))<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    age = fields.Int(validate=validate.Range(min=<span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">18<\/span>, max=<span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">40<\/span>))<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>in_data = {<span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'name'<\/span>: <span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">''<\/span>, <span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'permission'<\/span>: <span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'invalid'<\/span>, <span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'age'<\/span>: <span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">71<\/span>}<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">try<\/span>:<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    UserSchema().load(in_data)<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">except<\/span> ValidationError <span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">as<\/span> err:<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    pprint(err.messages)<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><\/code><\/pre>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u6bd4\u5982\u8fd9\u91cc\u7684 validate \u5b57\u6bb5\uff0c\u6211\u4eec\u5206\u522b\u6821\u9a8c\u4e86 name\u3001permission\u3001age \u4e09\u4e2a\u5b57\u6bb5\uff0c\u6821\u9a8c\u65b9\u5f0f\u5404\u4e0d\u76f8\u540c\u3002<\/p>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u5982 name \u6211\u4eec\u8981\u5224\u65ad\u5176\u6700\u5c0f\u503c\u4e3a 1\uff0c\u5219\u4f7f\u7528\u4e86 Length \u5bf9\u8c61\u3002permission \u5fc5\u987b\u8981\u662f\u51e0\u4e2a\u5b57\u7b26\u4e32\u4e4b\u4e00\uff0c\u8fd9\u91cc\u53c8\u4f7f\u7528\u4e86 OneOf \u5bf9\u8c61\uff0cage \u53c8\u5fc5\u987b\u662f\u4ecb\u4e8e\u67d0\u4e2a\u8303\u56f4\u4e4b\u95f4\uff0c\u8fd9\u91cc\u5c31\u4f7f\u7528\u4e86 Range \u5bf9\u8c61\u3002<\/p>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u4e0b\u9762\u6211\u4eec\u6545\u610f\u4f20\u5165\u4e00\u4e9b\u9519\u8bef\u7684\u6570\u636e\uff0c\u770b\u4e0b\u8fd0\u884c\u7ed3\u679c\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><code style=\"padding: 16px; max-width: 100%; overflow-x: auto; background: #272822; color: #dddddd; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; border-radius: 0px; font-size: 12px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">{<span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'age'<\/span>: [<span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'Must be greater than or equal to 18 and less than or equal to 40.'<\/span>],<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/> <span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'name'<\/span>: [<span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'Shorter than minimum length 1.'<\/span>],<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/> <span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'permission'<\/span>: [<span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'Must be one of: read, write, admin.'<\/span>]}<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><\/code><\/pre>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u53ef\u4ee5\u770b\u5230\uff0c\u8fd9\u91cc\u4e5f\u8fd4\u56de\u4e86\u6570\u636e\u9a8c\u8bc1\u7684\u7ed3\u679c\uff0c\u5bf9\u4e8e\u4e0d\u7b26\u5408\u6761\u4ef6\u7684\u5b57\u6bb5\uff0c\u4e00\u4e00\u8fdb\u884c\u8bf4\u660e\u3002<\/p>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u53e6\u5916\u6211\u4eec\u4e5f\u53ef\u4ee5\u81ea\u5b9a\u4e49\u9a8c\u8bc1\u65b9\u6cd5\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><code style=\"padding: 16px; max-width: 100%; overflow-x: auto; background: #272822; color: #dddddd; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; border-radius: 0px; font-size: 12px; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">from<\/span> marshmallow <span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">import<\/span> Schema, fields, ValidationError<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">def<\/span> <span style=\"max-width: 100%; color: #a6e22e; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">validate_quantity<\/span><span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">(n)<\/span>:<\/span><br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    <span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">if<\/span> n &lt; <span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">0<\/span>:<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>        <span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">raise<\/span> ValidationError(<span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'Quantity must be greater than 0.'<\/span>)<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    <span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">if<\/span> n &gt; <span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">30<\/span>:<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>        <span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">raise<\/span> ValidationError(<span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'Quantity must not be greater than 30.'<\/span>)<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">class<\/span> <span style=\"max-width: 100%; font-weight: bold; color: white; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">ItemSchema<\/span><span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">(Schema)<\/span>:<\/span><br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    quantity = fields.Integer(validate=validate_quantity)<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>in_data = {<span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'quantity'<\/span>: <span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">31<\/span>}<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">try<\/span>:<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    result = ItemSchema().load(in_data)<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">except<\/span> ValidationError <span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">as<\/span> err:<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    print(err.messages)<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><\/code><\/pre>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u901a\u8fc7\u81ea\u5b9a\u4e49\u65b9\u6cd5\uff0c\u540c\u6837\u53ef\u4ee5\u5b9e\u73b0\u66f4\u7075\u6d3b\u7684\u9a8c\u8bc1\uff0c\u8fd0\u884c\u7ed3\u679c\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><code style=\"padding: 16px; max-width: 100%; overflow-x: auto; background: #272822; color: #dddddd; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; border-radius: 0px; font-size: 12px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">{<span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'quantity'<\/span>: [<span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'Quantity must not be greater than 30.'<\/span>]}<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><\/code><\/pre>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u5bf9\u4e8e\u4e0a\u9762\u7684\u4f8b\u5b50\uff0c\u8fd8\u6709\u66f4\u4f18\u96c5\u7684\u5199\u6cd5\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><code style=\"padding: 16px; max-width: 100%; overflow-x: auto; background: #272822; color: #dddddd; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; border-radius: 0px; font-size: 12px; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">from<\/span> marshmallow <span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">import<\/span> fields, Schema, validates, ValidationError<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">class<\/span> <span style=\"max-width: 100%; font-weight: bold; color: white; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">ItemSchema<\/span><span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">(Schema)<\/span>:<\/span><br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    quantity = fields.Integer()<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    <br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><span style=\"max-width: 100%; color: #75715e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">    @validates('quantity')<\/span><br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    <span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">def<\/span> <span style=\"max-width: 100%; color: #a6e22e; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">validate_quantity<\/span><span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">(self, value)<\/span>:<\/span><br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>        <span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">if<\/span> value &lt; <span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">0<\/span>:<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>            <span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">raise<\/span> ValidationError(<span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'Quantity must be greater than 0.'<\/span>)<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>        <span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">if<\/span> value &gt; <span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">30<\/span>:<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>            <span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">raise<\/span> ValidationError(<span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'Quantity must not be greater than 30.'<\/span>)<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><\/code><\/pre>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u901a\u8fc7\u5b9a\u4e49\u65b9\u6cd5\u5e76\u7528 validates \u4fee\u9970\u7b26\uff0c\u4f7f\u5f97\u4ee3\u7801\u7684\u4e66\u5199\u66f4\u52a0\u7b80\u6d01\u3002<\/p>\n<h2 style=\"margin-top: 20px; margin-right: 10px; font-weight: bold; font-size: 24px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><span style=\"padding-left: 10px; max-width: 100%; font-family: STHeitiSC-Light; font-size: 18px; font-weight: bolder; display: inline-block; border-left: 5px solid #f83929; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u5fc5\u586b\u5b57\u6bb5<\/span><\/h2>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u5982\u679c\u8981\u60f3\u5b9a\u4e49\u5fc5\u586b\u5b57\u6bb5\uff0c\u53ea\u9700\u8981\u5728 fields \u91cc\u9762\u52a0\u5165 required \u53c2\u6570\u5e76\u8bbe\u7f6e\u4e3a True \u5373\u53ef\uff0c\u53e6\u5916\u6211\u4eec\u8fd8\u53ef\u4ee5\u81ea\u5b9a\u4e49\u9519\u8bef\u4fe1\u606f\uff0c\u4f7f\u7528 error_messages \u5373\u53ef\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><code style=\"padding: 16px; max-width: 100%; overflow-x: auto; background: #272822; color: #dddddd; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; border-radius: 0px; font-size: 12px; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">from<\/span> pprint <span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">import<\/span> pprint<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">from<\/span> marshmallow <span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">import<\/span> Schema, fields, ValidationError<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">class<\/span> <span style=\"max-width: 100%; font-weight: bold; color: white; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">UserSchema<\/span><span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">(Schema)<\/span>:<\/span><br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    name = fields.String(required=<span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">True<\/span>)<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    age = fields.Integer(required=<span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">True<\/span>, error_messages={<span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'required'<\/span>: <span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'Age is required.'<\/span>})<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    city = fields.String(<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>        required=<span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">True<\/span>,<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>        error_messages={<span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'required'<\/span>: {<span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'message'<\/span>: <span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'City required'<\/span>, <span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'code'<\/span>: <span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">400<\/span>}},<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    )<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    email = fields.Email()<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">try<\/span>:<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    result = UserSchema().load({<span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'email'<\/span>: <span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'foo@bar.com'<\/span>})<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">except<\/span> ValidationError <span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">as<\/span> err:<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    pprint(err.messages)<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><\/code><\/pre>\n<h2 style=\"margin-top: 20px; margin-right: 10px; font-weight: bold; font-size: 24px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><span style=\"padding-left: 10px; max-width: 100%; font-family: STHeitiSC-Light; font-size: 18px; font-weight: bolder; display: inline-block; border-left: 5px solid #f83929; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u9ed8\u8ba4\u5b57\u6bb5<\/span><\/h2>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u5bf9\u4e8e\u5e8f\u5217\u5316\u548c\u53cd\u5e8f\u5217\u5316\u5b57\u6bb5\uff0cmarshmallow \u8fd8\u63d0\u4f9b\u4e86\u9ed8\u8ba4\u503c\uff0c\u800c\u4e14\u533a\u5206\u5f97\u975e\u5e38\u6e05\u695a\uff01\u5982 missing \u5219\u662f\u5728\u53cd\u5e8f\u5217\u5316\u65f6\u81ea\u52a8\u586b\u5145\u7684\u6570\u636e\uff0cdefault \u5219\u662f\u5728\u5e8f\u5217\u5316\u65f6\u81ea\u52a8\u586b\u5145\u7684\u6570\u636e\u3002<\/p>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u4f8b\u5982\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><code style=\"padding: 16px; max-width: 100%; overflow-x: auto; background: #272822; color: #dddddd; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; border-radius: 0px; font-size: 12px; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">from<\/span> marshmallow <span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">import<\/span> Schema, fields<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">import<\/span> datetime <span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">as<\/span> dt<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">import<\/span> uuid<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">class<\/span> <span style=\"max-width: 100%; font-weight: bold; color: white; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">UserSchema<\/span><span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">(Schema)<\/span>:<\/span><br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    id = fields.UUID(missing=uuid.uuid1)<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    birthdate = fields.DateTime(default=dt.datetime(<span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">2017<\/span>, <span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">9<\/span>, <span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">29<\/span>))<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>print(UserSchema().load({}))<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>print(UserSchema().dump({}))<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><\/code><\/pre>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u8fd9\u91cc\u6211\u4eec\u90fd\u662f\u5b9a\u4e49\u7684\u7a7a\u6570\u636e\uff0c\u5206\u522b\u8fdb\u884c\u5e8f\u5217\u5316\u548c\u53cd\u5e8f\u5217\u5316\uff0c\u8fd0\u884c\u7ed3\u679c\u5982\u4e0b\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><code style=\"padding: 16px; max-width: 100%; overflow-x: auto; background: #272822; color: #dddddd; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; border-radius: 0px; font-size: 12px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">{<span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'id'<\/span>: UUID(<span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'06aa384a-570c-11ea-9869-a0999b0d6843'<\/span>)}<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>{<span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'birthdate'<\/span>: <span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'2017-09-29T00:00:00'<\/span>}<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><\/code><\/pre>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u53ef\u4ee5\u770b\u5230\uff0c\u5728\u6ca1\u6709\u771f\u5b9e\u503c\u7684\u60c5\u51b5\u4e0b\uff0c\u5e8f\u5217\u5316\u548c\u53cd\u5e8f\u5217\u5316\u90fd\u662f\u7528\u4e86\u9ed8\u8ba4\u503c\u3002<\/p>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u8fd9\u4e2a\u771f\u7684\u662f\u89e3\u51b3\u4e86\u6211\u4e4b\u524d\u5728 cattrs \u5e8f\u5217\u5316\u548c\u53cd\u5e8f\u5217\u5316\u65f6\u5019\u7684\u75db\u70b9\u554a\uff01<\/p>\n<h2 style=\"margin-top: 20px; margin-right: 10px; font-weight: bold; font-size: 24px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><span style=\"padding-left: 10px; max-width: 100%; font-family: STHeitiSC-Light; font-size: 18px; font-weight: bolder; display: inline-block; border-left: 5px solid #f83929; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u6307\u5b9a\u5c5e\u6027\u540d<\/span><\/h2>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u5728\u5e8f\u5217\u5316\u65f6\uff0cSchema \u5bf9\u8c61\u4f1a\u9ed8\u8ba4\u4f7f\u7528\u548c\u81ea\u8eab\u5b9a\u4e49\u76f8\u540c\u7684 fields \u5c5e\u6027\u540d\uff0c\u5f53\u7136\u4e5f\u53ef\u4ee5\u81ea\u5b9a\u4e49\uff0c\u5982\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><code style=\"padding: 16px; max-width: 100%; overflow-x: auto; background: #272822; color: #dddddd; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; border-radius: 0px; font-size: 12px; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">class<\/span> <span style=\"max-width: 100%; font-weight: bold; color: white; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">UserSchema<\/span><span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">(Schema)<\/span>:<\/span><br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    name = fields.String()<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    email_addr = fields.String(attribute=<span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'email'<\/span>)<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    date_created = fields.DateTime(attribute=<span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'created_at'<\/span>)<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>user = User(<span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'Keith'<\/span>, email=<span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'keith@stones.com'<\/span>)<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>ser = UserSchema()<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>result, errors = ser.dump(user)<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>pprint(result)<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><\/code><\/pre>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u8fd0\u884c\u7ed3\u679c\u5982\u4e0b\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><code style=\"padding: 16px; max-width: 100%; overflow-x: auto; background: #272822; color: #dddddd; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; border-radius: 0px; font-size: 12px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">{'name': 'Keith',<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/> 'email_addr': 'keith@stones.com',<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/> 'date_created': '2014-08-17T14:58:57.600623+00:00'}<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><\/code><\/pre>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u53cd\u5e8f\u5217\u5316\u4e5f\u662f\u4e00\u6837\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><code style=\"padding: 16px; max-width: 100%; overflow-x: auto; background: #272822; color: #dddddd; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; border-radius: 0px; font-size: 12px; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">class<\/span> <span style=\"max-width: 100%; font-weight: bold; color: white; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">UserSchema<\/span><span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">(Schema)<\/span>:<\/span><br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    name = fields.String()<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    email = fields.Email(load_from=<span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'emailAddress'<\/span>)<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>data = {<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    <span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'name'<\/span>: <span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'Mike'<\/span>,<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    <span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'emailAddress'<\/span>: <span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'foo@bar.com'<\/span><br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>}<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>s = UserSchema()<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>result, errors = s.load(data)<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><\/code><\/pre>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u8fd0\u884c\u7ed3\u679c\u5982\u4e0b\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><code style=\"padding: 16px; max-width: 100%; overflow-x: auto; background: #272822; color: #dddddd; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; border-radius: 0px; font-size: 12px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">{'name': u'Mike',<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/> 'email': 'foo@bar.com'}<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><\/code><\/pre>\n<h2 style=\"margin-top: 20px; margin-right: 10px; font-weight: bold; font-size: 24px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><span style=\"padding-left: 10px; max-width: 100%; font-family: STHeitiSC-Light; font-size: 18px; font-weight: bolder; display: inline-block; border-left: 5px solid #f83929; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u5d4c\u5957\u5c5e\u6027<\/span><\/h2>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u5bf9\u4e8e\u5d4c\u5957\u5c5e\u6027\uff0cmarshmallow \u5f53\u7136\u4e5f\u4e0d\u5728\u8bdd\u4e0b\uff0c\u8fd9\u4e5f\u662f\u8ba9\u6211\u89c9\u5f97 marshmallow \u975e\u5e38\u597d\u7528\u7684\u5730\u65b9\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><code style=\"padding: 16px; max-width: 100%; overflow-x: auto; background: #272822; color: #dddddd; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; border-radius: 0px; font-size: 12px; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">from<\/span> datetime <span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">import<\/span> date<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">from<\/span> marshmallow <span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">import<\/span> Schema, fields, pprint<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">class<\/span> <span style=\"max-width: 100%; font-weight: bold; color: white; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">ArtistSchema<\/span><span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">(Schema)<\/span>:<\/span><br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    name = fields.Str()<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\"><span style=\"max-width: 100%; color: #f92672; font-weight: bold; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">class<\/span> <span style=\"max-width: 100%; font-weight: bold; color: white; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">AlbumSchema<\/span><span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">(Schema)<\/span>:<\/span><br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    title = fields.Str()<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    release_date = fields.Date()<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>    artist = fields.Nested(ArtistSchema())<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>bowie = dict(name=<span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'David Bowie'<\/span>)<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>album = dict(artist=bowie, title=<span style=\"max-width: 100%; color: #a6e22e; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">'Hunky Dory'<\/span>, release_date=date(<span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">1971<\/span>, <span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">12<\/span>, <span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">17<\/span>))<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>schema = AlbumSchema()<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>result = schema.dump(album)<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/>pprint(result, indent=<span style=\"max-width: 100%; line-height: 26px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">2<\/span>)<br style=\"max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;\" \/><\/code><\/pre>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u8fd9\u6837\u6211\u4eec\u5c31\u80fd\u5145\u5206\u5229\u7528\u597d\u5bf9\u8c61\u5173\u8054\u5916\u952e\u6765\u65b9\u4fbf\u5730\u5b9e\u73b0\u5f88\u591a\u5173\u8054\u529f\u80fd\u3002<\/p>\n<p style=\"margin: 10px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; min-height: 1em; line-height: 1.75; letter-spacing: 0.2em; font-size: 14px; word-spacing: 0.1em; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\u4ee5\u4e0a\u4ecb\u7ecd\u7684\u5185\u5bb9\u57fa\u672c\u7b97\u5728\u65e5\u5e38\u7684\u4f7f\u7528\u4e2d\u662f\u591f\u7528\u4e86\uff0c\u5f53\u7136\u4ee5\u4e0a\u90fd\u662f\u4e00\u4e9b\u57fa\u672c\u7684\u793a\u4f8b\uff0c\u5bf9\u4e8e\u66f4\u591a\u529f\u80fd\uff0c\u53ef\u4ee5\u53c2\u8003 marchmallow \u7684\u5b98\u65b9\u6587\u6863\uff1ahttps:\/\/marshmallow.readthedocs.io\/en\/stable\/\uff0c\u5f3a\u70c8\u63a8\u8350\u5927\u5bb6\u7528\u8d77\u6765\u3002<\/p>\n<\/section>\n<p style=\"white-space: normal; text-align: center;\"><span style=\"font-size: 15px; color: #888888;\">&#8211; EOF &#8211;<\/span><\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u5f88\u591a\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u4f1a\u6709\u628a Python \u5bf9\u8c61\u8fdb\u884c\u5e8f\u5217\u5316\u6216\u53cd\u5e8f\u5217\u5316\u7684\u9700\u6c42\uff0c\u6bd4\u5982\u5f00\u53d1 REST API\uff0c\u6bd4\u5982\u4e00\u4e9b\u9762 &hellip; <a href=\"http:\/\/www.zhushiyao.com\/?p=67645\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201cmarshmallow\uff0c\u652f\u6301 Python \u5bf9\u8c61\u548c\u539f\u751f\u6570\u636e\u76f8\u4e92\u8f6c\u6362\u7684\u5e93\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[8],"_links":{"self":[{"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=\/wp\/v2\/posts\/67645"}],"collection":[{"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=67645"}],"version-history":[{"count":2,"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=\/wp\/v2\/posts\/67645\/revisions"}],"predecessor-version":[{"id":67648,"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=\/wp\/v2\/posts\/67645\/revisions\/67648"}],"wp:attachment":[{"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=67645"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=67645"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=67645"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}