源代码如下,使用python3.7和3.8版本运行均报错为TypeError: 'type' object is not subscriptable
使用python3.10运行结果成功。
下述为类型注释相关知识点,运行成功需要较高版本的python
def time(s:dict[str, int], n:int = 3) -> list:
return list(s.keys()) * n
print(time({'A': 1, 'B': 2, 'C': 3}))
最后
以上就是爱笑西装最近收集整理的关于TypeError: ‘type‘ object is not subscriptable的全部内容,更多相关TypeError:内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复