import sxtwl
lunar = sxtwl.Lunar()
Gan = ["甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸"]
Zhi = ["子", "醜", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"]
ShX = ["鼠", "牛", "虎", "兔", "龍", "蛇", "馬", "羊", "猴", "雞", "狗", "豬"]
numCn = ["零", "一", "二", "三", "四", "五", "六", "七", "八", "九", "十"]
Week = ["日", "一", "二", "三", "四", "五", "六"]
jqmc = ["冬至", "小寒", "大寒", "立春", "雨水", "驚蟄", "春分", "清明", "穀雨", "立夏", "小滿", "芒種", "夏至", "小暑", "大暑", "立秋", "處暑","白露", "秋分", "寒露", "霜降", "立冬", "小雪", "大雪"]
ymc = ["十一", "十二", "正", "二", "三", "四", "五", "六", "七", "八", "九", "十" ]
rmc = ["初一", "初二", "初三", "初四", "初五", "初六", "初七", "初八", "初九", "初十", "十一", "十二", "十三", "十四", "十五", "十六", "十七", "十八", "十九", "二十", "廿一", "廿二", "廿三", "廿四", "廿五", "廿六", "廿七", "廿八", "廿九", "三十", "卅一"]
#打印做一箇中間轉(zhuǎn)換
def log(*arg):
s = ""
for v in arg:
s += str(v)
print(s)
def printDay(day):
log("===================================================")
log("公曆:", day.y, "年", day.m, "月", day.d, "日")
if day.Lleap:
log("潤", (day.Lyear0 + 1984), "年", ymc[day.Lmc], "月", rmc[day.Ldi], "日")
else:
log((day.Lyear0 + 1984), "年", ymc[day.Lmc], "月", rmc[day.Ldi], "日")
if (day.qk >= 0):
log("當(dāng)日節(jié)氣:" + jqmc[day.jqmc])
log("節(jié)氣時(shí)間:" + day.jqsj)
log("儒略日:JD", sxtwl.J2000 + day.d0)
log("星期", Week[day.week])
log(Gan[day.Lyear2.tg], Zhi[day.Lyear2.dz], "年", Gan[day.Lmonth2.tg], Zhi[day.Lmonth2.dz], "月", \
Gan[day.Lday2.tg], Zhi[day.Lday2.dz], "日")
log("距冬至", day.cur_dz, "天")
log("距夏至", day.cur_xz, "天")
log("距立秋", day.cur_lq, "天")
log("距芒種", day.cur_mz, "天")
log("距小暑", day.cur_xs, "天")
day = lunar.getDayByLunar(2018, 10, 20 )
printDay(day)
gz = lunar.getShiGz(2, 12) #第一個(gè)參數(shù)為生日的日天干,參數(shù)二為出生的時(shí)間(小時(shí))
print( Gan[gz.tg], Zhi[gz.dz])
#獲取時(shí)辰上的那個(gè)天干(例如拿下午13點(diǎn)的時(shí)辰干支)
gz = lunar.getShiGz(day.Lday2.tg, 13);
log("獲取時(shí)辰的干支:" + Gan[gz.tg] + Zhi[gz.dz]);
log("===================================================")
#獲取一年的信息(干支,生肖,)
year = lunar.getYearCal(2018);
log("獲取年的干支:" + Gan[year.yearGan] + Zhi[year.yearZhi]);
log("獲取年的生肖:" + ShX[year.ShX]);
好用的Python第三方日歷庫:sxtwl(可算天干地支)
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
- 文/潘曉璐 我一進(jìn)店門黄锤,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人食拜,你說我怎么就攤上這事鸵熟。” “怎么了负甸?”我有些...
- 文/不壞的土叔 我叫張陵流强,是天一觀的道長。 經(jīng)常有香客問我惑惶,道長煮盼,這世上最難降的妖魔是什么? 我笑而不...
- 正文 為了忘掉前任带污,我火速辦了婚禮,結(jié)果婚禮上香到,老公的妹妹穿的比我還像新娘鱼冀。我一直安慰自己报破,他們只是感情好,可當(dāng)我...
- 文/花漫 我一把揭開白布千绪。 她就那樣靜靜地躺著充易,像睡著了一般。 火紅的嫁衣襯著肌膚如雪荸型。 梳的紋絲不亂的頭發(fā)上盹靴,一...
- 文/蒼蘭香墨 我猛地睜開眼蔓倍,長吁一口氣:“原來是場噩夢啊……” “哼悬钳!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起偶翅,我...
- 序言:老撾萬榮一對(duì)情侶失蹤默勾,失蹤者是張志新(化名)和其女友劉穎,沒想到半個(gè)月后聚谁,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體母剥,經(jīng)...
- 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
- 正文 我和宋清朗相戀三年垦巴,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了媳搪。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
- 正文 年R本政府宣布,位于F島的核電站芬膝,受9級(jí)特大地震影響望门,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜锰霜,卻給世界環(huán)境...
- 文/蒙蒙 一筹误、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧癣缅,春花似錦厨剪、人聲如沸哄酝。這莊子的主人今日做“春日...
- 文/蒼蘭香墨 我抬頭看了看天上的太陽陶衅。三九已至,卻和暖如春直晨,著一層夾襖步出監(jiān)牢的瞬間搀军,已是汗流浹背。 一陣腳步聲響...
- 正文 我出身青樓儒士,卻偏偏與公主長得像的止,于是被迫代替她去往敵國和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子着撩,可洞房花燭夜當(dāng)晚...