# 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)
# 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)