目录
题目: 力扣
思路:
题目: 力扣
思路:
我横竖一看:好家伙,这不就是菜鸟上的题目吗?
思路很简单
先将数据进行处理
然后判断是不是闰年(是的话,二月分数据加一)
class Solution:def dayOfYear(self, date: str) -> int:year,month,day = [int(x) for x in date.split("-")]amount = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]if year %400 == 0 or (year % 100 != 0 and year % 4 == 0):amount[1] += 1ans = sum(amount[:month-1])return day+ans