# 请先使用命令 pip install sxtwl 安装依赖库后,再执行以下脚本 import sxtwl ymc = ["正", "二", "三", "四", "五", "六", "七", "八", "九", "十" ,"冬", "腊"] rmc = ["初一", "初二", "初三", "初四", "初五", "初六", "初七", "初八", "初九", "初十", "十一", "十二", "十三", "十四", "十五", "十六", "十七", "十八", "十九", "二十", "廿一", "廿二", "廿三", "廿四", "廿五", "廿六", "廿七", "廿八", "廿九", "三十", "卅一"] csrq = sxtwl.fromSolar(1990, 1, 1) # 在此填写自己的公历出生日期 csn = csrq.getSolarYear() csgly = csrq.getSolarMonth() csglr = csrq.getSolarDay() csnly = csrq.getLunarMonth() csnlr = csrq.getLunarDay() czdns = 100 # 从出生年开始,遍历查找多少年 tytdcs = 0 # 记录同一天的次数 print("==================================================") for year in range(csn, csn + czdns): day = sxtwl.fromSolar(year, csgly, csglr) if day.getLunarMonth() == csnly and day.getLunarDay() == csnlr: tytdcs += 1 print("第", tytdcs, "次,公历与农历生日在同一天") if((year - csn) == 0): print("我出生啦!") else: print("我", (year - csn), "岁") print("公历:" + str(day.getSolarYear()) + " 年 " + str(day.getSolarMonth()) + " 月 " + str(day.getSolarDay()) + " 日") print("农历:" + ymc[day.getLunarMonth()-1] + "月" + rmc[day.getLunarDay()-1]) print("==================================================")
参考来源:https://blog.csdn.net/m0_53623159/article/details/121843476
https://www.cnblogs.com/Eleven-Liu/p/11142703.html文章来源:https://www.toymoban.com/news/detail-416646.html
https://pypi.org/project/sxtwl/文章来源地址https://www.toymoban.com/news/detail-416646.html
到了这里,关于查找自己农历生日与公历生日在同一天的年份的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!