# 'primes' is a list of integers
primes = [] # type: List[int]# 'captain' is a string (Note: initial value is a problem)
captain = ... # type: strclassStarship:# 'stats' is a class variable
stats = {} # type: Dict[str, int]
使用了类型提示
from typing importList, ClassVar, Dict# int 变量,默认值为 0
num: int = 0# bool 变量,默认值为 True
bool_var: bool = True# 字典变量,默认为空
dict_var: Dict = {}
# 列表变量,且列表元素为 int
primes: List[int] = []
classStarship:# 类变量,字典类型,键-字符串,值-整型
stats: ClassVar[Dict[str, int]] = {}
# 实例变量,标注了是一个整型
num: int