python - python 中 date.toordinal() 的倒数是什么?

标签 python date

在 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/

相关文章:

python - python中的计算静态属性

Python数据框,删除特定记录之后的所有内容

python - 训练 TensorFlow 预测总和

javascript - 为什么 New Date() 总是返回 null?

java - 如何在对 Spring MVC Controller 的 GET 请求中接受日期参数?

php - 如何在 python 或 ruby​​ 中执行此操作(PHP)?

Python 双循环

python - Dataframe:为缺失日期添加新行

javascript - 制定基本日期(技术)

javascript - Google Charts ColumnChart 日期格式不显示分钟和小时