如何在 python 中将字符串转换为儒略日期

how to convert a string into julian date in python

我的table一个字段格式类似“8192009”,类型是字符串。我需要将它转换成朱利安日期。比如一年有多少天。 我试过了

>>> from datetime import datetime
>>> date_object=datetime.strptime("8192009","%b%d%Y")

它给我 ValueError:时间数据“8192009”与格式“%b%d%Y”不匹配

试试这个:

>>> date_object=datetime.strptime("Aug192009","%b%d%Y")
>>> date_object
datetime.datetime(2009, 8, 19, 0, 0)
>>> 

或者这个:

>>> date_object=datetime.strptime("8192009","%m%d%Y")
>>> date_object
datetime.datetime(2009, 8, 19, 0, 0)
>>>