python中date.toordinal()的倒数是什么?
在python中,python中date.toordinal()的倒数是什么?,python,date,Python,Date,在python中,date对象可以通过以下方式转换为序言格里高利序号: d=datetime.date(year=2010, month=3, day=1) d.toordinal() 但是什么是反向操作呢?这是Jon在评论中写到的date.fromordial() 或datetime.fromordinal() 你可以在 以及 从文档中: classmethoddate.fromordinal(ordinal) 返回相应的日期 第1年的1月1日 序号1ValueError被引发,除非1相反
date
对象可以通过以下方式转换为序言格里高利序号:
d=datetime.date(year=2010, month=3, day=1)
d.toordinal()
但是什么是反向操作呢?这是Jon在评论中写到的date.fromordial()
或datetime.fromordinal()
你可以在
以及
从文档中:
classmethod
date.fromordinal(ordinal)
返回相应的日期
第1年的1月1日
序号1ValueError
被引发,除非1相反
classmethod date.fromordinal(ordinal)
返回与前公历序号对应的日期,
其中,第1年的1月1日具有序号1。除非
1我从中找到了答案
犯错误
>>> from datetime import datetime
>>> dt = datetime.fromordinal(733828)