在 python 中,date
对象可以这样转换为公历序数:
d=datetime.date(year=2010, month=3, day=1)
d.toordinal()
但是什么是逆运算呢?
最佳答案
相反的是date.fromordinal
classmethod date.fromordinal(ordinal)
Return the date corresponding to the proleptic Gregorian ordinal, where January 1 of year 1 has ordinal 1. ValueError is raised unless 1 <= ordinal <= date.max.toordinal(). For any date d, date.fromordinal(d.toordinal()) == d.
关于python - python 中 date.toordinal() 的倒数是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16542074/