·山师·开心中夹杂一丝丝不爽

随想

心情日记

今天整体来说是中规中矩吧,感谢qoderwork,哈哈哈哈从昨天开始,一直使用它帮我构建个人博客,从发布到部署,再一步步调优,然后到文章发布功能,也就是现在我正在使用的功能,哈哈哈哈哈,爽!

但是有个很不爽的事情,这破山师,假期间想盖个章非常之困难,一点人情味没有,讨厌…

放一段pydantic的代码在这里展示一下

# case 2 pydantic 使用
from pydantic import BaseModel
from typing import List, Dict, Tuple, Set

class DataModel(BaseModel):
    username: str
    id: int
    score: float 
    is_active: bool
    hobbies: List[str]
    info: Dict[str, int]
    coords: Tuple[int, float]
    tags: Set[str]
    remark: str | None = None

data = DataModel(
    username="张三",
    id = 1001,
    score = 98.5,
    is_active = True,
    hobbies=["篮球", "编程", "阅读"],
    info={"level": 5, "experience": 1000},
    coords=(100, 30.5),
    tags={"python", "pydantic", "learning"}
) 

print("多类型模型实例:")
print(f"用户名:{data.username}")
print(f"爱好列表:{data.hobbies}")
print(f"坐标元组:{data.coords}")
print(f"标签集合:{data.tags}")