擅长:python、mysql、java
<p>您需要决定是从<code>pydantic.BaseModel</code>继承,还是使用<code>@dataclass</code>装饰器(或者<code>from dataclasses</code>,或者<code>from pydantic.dataclasses</code>)</p>
<p>根据<a href="https://pydantic-docs.helpmanual.io/usage/dataclasses/" rel="noreferrer">documentation</a>(我自己加的黑体字),两者都可以,但不能同时使用:</p>
<blockquote>
<p><strong>If you don't want to use pydantic's BaseModel</strong> you can <strong>instead</strong> get the same data validation on standard dataclasses</p>
</blockquote>