Press "Enter" to skip to content

Month: March 2022

Python农历转换

在Python中进行公历转换农历, 是一件很简单的事儿.

>>> import datetime
>>> from zhdate import ZhDate

# 农历转公历
>>> date = ZhDate(2022,4,5)
>>> print(date)
农历2022年4月5日

>>> date.to_datetime().date().year
2022
>>> date.to_datetime().date().month
5
>>> date.to_datetime().date().day
5
Leave a Comment