如何计算当前年份是天干地支哪一年?
# -*- coding: utf-8 -*-
'''
判断今年是什么年份,例如:2019年为己亥年
'''
TG=['甲','乙','丙','丁','戊','己','庚','辛','壬','癸']
DZ=['子','丑','寅','卯','辰','巳','午','未','申','酉','戌','亥']
Year_Name=[]
x=0
y=0
n=1
while n<61:
if x==y and x<10:
Year_Name.append(TG[x]+DZ[y])
x+=1
y+=1
elif x<10 and y>=12:
y=y*0
Year_Name.append(TG[x]+DZ[y])
x+=1
y+=1
elif 9<x<=10 and 12>y>=10:
x = x * 0
Year_Name.append(TG[x] + DZ[y])
x+=1
y+=1
elif x<10 and y<10:
Year_Name.append(TG[x] + DZ[y])
x+=1
y+=1
elif x<10 and 12>y>=10:
Year_Name.append(TG[x] + DZ[y])
x += 1
y += 1
elif x == 10 and y<12:
x=x*0
Year_Name.append(TG[x] + DZ[y])
x += 1
y += 1
else:
pass
n+=1
# print(Year_Name)
# 1984 甲子年
Year=1984
Year_Num=[]
Year_Num.clear()
while (Year<2085):
Year_Num.append(Year)
Year=Year+1
# print(Year_Num)
dic={}
dic.clear()
i=0
n=0
if i==0:
for n in range(0,len(Year_Num),1):
dic[Year_Num[n]] = Year_Name[i]
i += 1
if i == 60:
i = i * 0
Year_S=input("请输入年份:")
print(dic.get(int(Year_S)))