Ⅰ 澶╁共鍦版敮涓囪兘璁$畻鍏寮忥紝澶╁共鍦版敮鐨勭畻娉
鎻愯搗澶╁共鍦版敮涓囪兘璁$畻鍏寮忥紝澶у墮兘鐭ラ亾錛屾湁浜洪棶澶╁共鍦版敮鐨勭畻娉曪紝鍙﹀栵紝榪樻湁浜烘兂闂1993騫達紝鐢ㄥ共鏀綰騫存槸浠涔堟椂鍊欙紝鎬庝箞璁$畻鐨勶紝鍏蜂綋鍏寮忥紝浣犵煡閬撹繖鏄鎬庝箞鍥炰簨錛熷叾瀹炴眰澶╁共鍦版敮鐨勮$畻鏂規硶錛屼笅闈㈠氨涓璧鋒潵鐪嬬湅澶╁共鍦版敮鐨勭畻娉曪紝甯屾湜鑳藉熷府鍔╁埌澶у訛紒
澶╁共錛氱敳銆佷箼銆佷笝銆佷竵銆佹垔銆佸繁銆佸簹銆佽緵銆佸,銆佺櫢
鍦版敮錛氬瓙銆佷笐銆佸瘏銆佸嵂銆佽景銆佸煩銆佸崍銆佹湭銆佺敵銆侀厜銆佹垖銆佷亥鍦版敮鏈夊皬鏁扮偣鐨勬庝箞綆椼
澶╁共=錛堝勾浠-3錛/10鈥︹︿綑鏁頒綑鏁頒負鍑犲氨鏁板嚑涓
鍦版敮=錛堝勾浠-3錛/12鈥︹︿綑鏁板悓涓
姣斿備粖騫村ぉ騫插湴鏀鏈姝g『鐨勭畻娉曘
錛-3錛/10鈥︹︿綑鏁頒負0鏁板嶮涓灝辨槸鐧
錛-3錛/12鈥︹︿綑鏁頒負6鏁板叚涓鏄宸
鏉ユ簮嫻呰
鐩鎬紶鏃╁湪鍏鍏冨墠騫達紝浜庝腑鍗庡嬬栭粍甯濆緩鍥芥椂錛屽懡澶ф尃姘忔帰瀵熷ぉ鍦頒箣姘旀満錛屾帰絀朵簲琛屻
涓浜涘﹁呬粠涓鍥戒笂鍙ょ殑澶忎唬甯濈帇涓栫郴鍜屽晢浠f堡鐜嬩互涓嬫墍鏈夊笣鐜嬬殑鍚嶅瓧涓錛屾帰絀跺嶮澶╁共涓鐨勫瓧宸茶鐢ㄤ簬榪欎竴鐗規湁鐜拌薄銆傞儜鏂囧厜鍦ㄦ墍钁椼婁腑鍥藉ぉ鏂囧︽簮嫻併嬩竴涔︿腑璁や負錛屽嶮澶╁共璧鋒簮浜庝腑鍥藉彜浠g靜鍜屸滅敓鍗佹棩鈥濈殑紲炶瘽錛屾槸鍗佽繘浣嶆硶姒傚康鍦ㄧ邯鏃朵腑鐨勫弽鏄狅紝搴斿綋浜х敓浜庢笖鐚庢椂浠g殑鍘熷嬶紱鈥滃嶮浜屽湴鏀鈥濆垯鐢卞父緹測滅敓鏈堝嶮鏈変簩鈥濈殑紲炶瘽婕斿彉鑰屾潵錛屼駭鐢熶簬孌峰晢涔嬪墠錛屽悗閫愭笎婕斿彉涓哄嶮浜岃景銆傛墍浠ワ紝閮戞枃鍏夋帹鏂錛氣滃嶮浜屾敮瀹滀箮鏄澶忎漢鐨勫壋浣溿傗
闄堥伒濡鍦ㄣ婁腑鍥藉ぉ鏂囧﹀彶銆嬩腑鎸囧嚭錛屸滃湪鍥涘崈澶氬勾鍓嶇殑澶忎唬錛屽彲鑳藉凡鏈夊共鏀浜х敓浜嗏濄傛潨鐭崇劧絳夊垯鍦ㄧ紪钁楃殑銆婁腑鍥界戝︽妧鏈鍙茬褲嬩竴涔︿腑錛屼富寮犲忎唬宸叉湁鍗佸ぉ騫茬邯鏃ユ硶錛屽晢浠e湪澶忎唬澶╁共綰鏃ョ殑鍩虹涓婏紝榪涗竴姝ヤ嬌鐢ㄥ共鏀綰娉曪紝浠庤屾妸鍗佸ぉ騫插拰鍗佷簩鍦版敮閰嶅悎鍦ㄤ竴璧峰艦鎴愬叚鍗佸驚鐜鐨勭邯鏃ユ硶銆傚ぉ騫插湴鏀鎸囨爣鍏寮忋
澶х害鍦ㄦ垬鍥芥湯騫達紝渚濇嵁鍚勫浗鍙插畼闀挎湡縐緔涓嬫潵鐨勬潗鏂欑紪鎴愮殑鍙蹭功銆婁笘鏈銆嬭達細鈥滃規垚浣滃巻錛屽ぇ妗′綔鐢插瓙鈥濓紝銆婂皻涔︽d箟銆嬭В閲婅達細鈥滀簩浜虹殕榛勫笣涔嬭嚕錛岀洊鑷榛勫笣浠ユ潵錛屽嬬敤鐢插瓙綰鏃ワ紝姣忓叚鍗佹棩鑰岀敳瀛愪竴鍛ㄢ濄傜湅鏀鏄澶ф鍒涘埗鐨勶紝澶ф鈥滈噰浜旇屼箣鎯咃紝鍗犳枟鏈烘墍寤猴紝濮嬩綔鐢蹭箼浠ュ悕鏃ワ紝璋撲箣騫詫紱浣滃瓙涓戜互鍚嶆湀錛岃皳涔嬫灊錛屾湁浜嬩簬澶╁垯鐢ㄦ棩錛屾湁浜嬩簬鍦板垯鐢ㄦ湀錛屼箣鍒錛屾晠鏈夋灊騫插悕涔熴傗
騫叉敮綰騫存硶錛屾垜鍥戒紶緇熺殑綰騫存柟娉曘
1錛庡共鍜屾敮鐨勫惈涔夛細騫叉敮鏄澶╁共錛屽湴鏀鐨勫悎縐般
鍗佸ぇ澶╁共錛氱敳涓佸簹鐧
鍗佷簩鍦版敮錛氬瓙錛堥紶)
涓(鐗)
瀵咃紙鉶庯級
鍗錛堝厰錛
杈幫紙榫欙級
宸籌紙錏囷級
鍗堬紙椹錛変換鎰忔棩騫叉敮宸х畻娉曘
鏈錛堢緤錛
鐢籌紙鐚達級
閰夛紙楦★級
鎴岋紙鐙楋級騫叉敮綰騫存硶綆渚跨畻娉曞叕寮忋
浜ワ紙鐚錛
2錛庡共鍜屾敮緇勫悎鍚庣敤浜庣邯騫淬傚嵆錛氬皢鍗佸ぉ騫插拰鍗佷簩鍦版敮鎸夐『搴忔惌閰嶇粍鍚堟垚騫叉敮錛岀敤浜庣邯騫淬傛寜姝ゆ帓娉曪紝鍙鏋勬垚60騫叉敮錛堝嵆涓轟竴鑺辯敳錛夈傜畫鎺掍笅鍘誨張灝嗘仮澶嶅師鐘訛紝鍛ㄨ屽嶅嬶紝姘告棤姝㈠敖銆傚嶮澶╁共鎵鏀銆
3銆佽$畻鏂規硶濡備笅錛氬簹杈版棩濂沖懡鐭銆
錛1錛夊皢鍗佸ぇ澶╁共銆佸嶮浜屽湴鏀緙栧彿銆傚備笅錛氫笝宸卞,瀛愬嵂鍗堥厜澶╁共鍦版敮鏃ユ湡璁$畻鍣ㄣ
錛2錛夎$畻鏃訛紝騫翠綅鐨勬暟瀵瑰簲澶╁共鐨勭紪鍙楓佺敤騫存暟闄や互12錛屽緱鍒扮殑浣欐暟瀵瑰簲鍦版敮鐨勭紪鍙鳳紝鍚堣搗鏉ュ氨鏄璇ュ勾鐨勫共鏀綰騫存硶銆傚ぉ騫插湴鏀鐨勮$畻鏂規硶銆
濡傚勾錛氫綅鏄1錛屽瑰簲鐨勫ぉ騫茬殑緙栧彿灝辨槸鈥滆緵鈥濓紝鍐嶇敤闄や互12寰楀埌浣7錛屽瑰簲鍦版敮緙栧彿涓衡滃嵂鈥濆悎璧鋒潵鍗沖勾涓衡滆緵鍗鈥濆勾銆傚垵涓鍘嗗彶鏃墮棿璁$畻鍏寮忋
浠ヤ笂灝辨槸涓庡ぉ騫插湴鏀鐨勭畻鍏沖唴瀹癸紝鏄鍏充簬澶╁共鍦版敮鐨勭畻娉曠殑鍒嗕韓銆傜湅瀹屽ぉ騫插湴鏀涓囪兘璁$畻鍏寮忓悗錛屽笇鏈涜繖瀵瑰ぇ瀹舵湁鎵甯鍔╋紒
Ⅱ python1900鍀2031騫,杈撳嚭姣忓勾鐨勫ぉ騫層佸湴鏀,鍒ゆ柇鏄鍚﹂棸騫村苟緇熻¢棸騫寸殑涓鏁幫紵
# 瀹氫箟澶╁共鍜屽湴鏀鐨勫垪琛╰iangan = ["鐢","涔","涓","涓","鎴","宸","搴","杈","澹","鐧"]
di = ["瀛","涓","瀵","鍗","杈","宸","鍗","鏈","鐢","閰","鎴","浜"]# 瀹氫箟涓涓鍑芥暟錛屽垽鏂鏄鍚︿負闂板勾def is_leap_year(year): if year % 4 == 0 and year % 100 != 0 or year % 400 == 0: return True
else: return False# 鍒濆嬪寲闂板勾鐨勪釜鏁頒負闆秎eap_count = 0# 閬嶅巻1900鍒2031騫達紝杈撳嚭姣忓勾鐨勫ぉ騫插湴鏀鍜屾槸鍚︿負闂板勾for year in range(1900,2032): # 璁$畻澶╁共鍜屽湴鏀鐨勭儲寮曪紝娉ㄦ剰瑕佸噺鍘1錛屽洜涓哄垪琛ㄤ粠闆跺紑濮
tiangan_index = (year - 1900) % 10 - 1
di_index = (year - 1900) % 12 - 1
# 杈撳嚭姣忓勾鐨勫ぉ騫插湴鏀
print(f"{year}騫存槸{tiangan[tiangan_index]}{di[di_index]}騫", end=" ")
# 鍒ゆ柇鏄鍚︿負闂板勾錛屽苟杈撳嚭緇撴灉
if is_leap_year(year): print("鏄闂板勾") # 緔鍔犻棸騫寸殑涓鏁
leap_count += 1
else: print("涓嶆槸闂板勾")# 杈撳嚭鎬誨叡鏈夊氬皯涓闂板勾 print(f"浠1900鍒2031騫達紝涓鍏辨湁{leap_count}涓闂板勾")
Ⅲ 用Python計算年份屬於哪個天乾地支 源代碼
這個是我原創的,如果有考慮不周的地方可以交流一下:
y=int(input("請輸入公歷年份(公元前請加「-」):"))
t=(y-4)%60%10
d=(y-4)%60%12
T=["甲","乙","丙","丁","戊","己","庚","辛","壬","癸"]
D=["子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥"]
print("{}年為:農歷{}{}年".format(y,T[t],D[d]))
運行結果: