python TypedDict 字典补全

# Python 3.5 之后可用,之前需要pip安装
from typing import TypedDict


# 每个字段必须
class Person(TypedDict):
    name: str
    age: int
    qq: str


p1_dict: Person = {
    "name": "大佬",
    "age": 18,
    "qq": "123456789"
}

print(p1_dict)

 

posted @ 2023-11-28 21:01  zwnsyw  阅读(75)  评论(0编辑  收藏  举报