Extract day of year and Julian day from a string date

前端 未结 9 2042
臣服心动
臣服心动 2020-11-27 06:51

I have a string \"2012.11.07\" in python. I need to convert it to date object and then get an integer value of day of year and also Julian day

9条回答
  •  醉话见心
    2020-11-27 06:58

    From the above examples, here is the one liner (non-Julian):

    import datetime
    
    doy = datetime.datetime.strptime('2014-01-01', '%Y-%m-%d').timetuple().tm_yday
    

提交回复
热议问题