Python 农历&公历日期转换

您所在的位置:网站首页 python日期转换为星期 Python 农历&公历日期转换

Python 农历&公历日期转换

#Python 农历&公历日期转换| 来源: 网络整理| 查看: 265

Python 农历&公历日期转换 安装Boraxpip install borax from borax.calendars.lunardate import LunarDate today = LunarDate.today() # 显示农历今日,即 七月初四 today

LunarDate(2020, 7, 4, 0)

today.animal today.year today.month today.day

‘鼠’ 2020 7 4

today.to_solar_date()

datetime.date(2020, 8, 22)

# 构建一个农历日期 today = LunarDate(2020,8,14,0) today

LunarDate(2020, 8, 14, 0)

# 公历转农历,哦也,今年的国庆是八月十五 today=LunarDate.from_solar_date(2020,10,1) today

LunarDate(2020, 8, 15, 0)

查询下每年公历10月1号的农历日期是中秋八月十五的年份 for i in range(100): theday = LunarDate.from_solar_date(2000+i,10,1) if theday.month==8 and theday.day==15: pass #years_count= theday.year-2014 print(theday) #years_count

LunarDate(2001, 8, 15, 0) LunarDate(2020, 8, 15, 0) LunarDate(2031, 8, 15, 0) LunarDate(2077, 8, 15, 0)



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3