Python Question: Year and Day of Year to date?

前端 未结 5 441
面向向阳花
面向向阳花 2020-11-27 17:13

I have a year value and a day of year and would like to convert to a date (day/month/year).

5条回答
  •  一整个雨季
    2020-11-27 18:02

    The toordinal() and fromordinal() functions of the date class could be used:

    from datetime import date
    date.fromordinal(date(year, 1, 1).toordinal() + days - 1)
    

提交回复
热议问题