NameError: name 'List' is not defined


leetcode 刷題的時候,遇到下列錯誤。
1 class Solution: ----> 2 def kidsWithCandies(self, candies: List[int], extraCandies: int) -> List[bool]: 3 #遍歷所有的孩子 4 #增加糖果數量 5 #查看是否是最多的糖果,是,if_max,增加True NameError: name 'List' is not defined


在最前部增加:
from typing import List
解決問題。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM