解决:cannot import name ‘Literal‘ from ‘typing‘
·
from typing import Tuple, Literal
ImportError: cannot import name 'Literal' from 'typing' (/usr/lib/python3.7/typing.py)
理由:因为 Literal 类型提示是在 Python 3.8 中引入的。在 Python 3.7 中,Literal 并不存在于 typing 模块中,所以会出现 ImportError 错误
解决一:升级python
解决二:换为from typing_extensions import Literal
更多推荐
所有评论(0)