from pydantic import BaseModel, ValidationError class Product(BaseModel): name: str price: float try: product = Product(name="Laptop", price="Free") # 錯誤:price 應為 float except ValidationError as e: print("驗證錯誤:") print(e)