python限定参数类型为list报错name List is not defined

shaode01 2019-07-06 08:22:53
class Solution: def isValidSudoku(self, board: List[List[str]]) -> bool: return False name List is not defined
...全文
2113 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
dust_dust 2019-07-07
  • 打赏
  • 举报
回复
在文件开始加入 from typing import List
Al_xie 2019-07-07
  • 打赏
  • 举报
回复
python在参数中的冒号语法为类型注释, 解释器运行中并不会强制检查其类型; 另列表类型应为小写list, 且python中好像没有类似typescript的列表元素类型的描述语法

37,743

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • WuKongSecurity@BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧