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)
人生苦短,慢慢潇洒。
nsyw.run
# 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)