这段代码容易理解,对python小白来说理解也不成问题,运行效果如下:
具体代码如下:
data= int (input("请输入您的出生日数:"))
month=int (input("请输入您的出生月份:"))
year=int (input("请输入您的出生年份:"))
if month==1 and data>=20 or month==2 and data<=18:
print("您的星座是水瓶座")
if month==1 and data>31:
print("您输入的日期有误,请重新输入")
elif month==2 and data>=19 or month==3 and data<=20:
print("您的星座是双鱼座")
if year % 4==0 and year % 100 !=0 or year % 400 ==0:
if month==2 and data>29 :
print("您输入的日期有误,请重新输入")
else:
if month==2 and data>28 :
print("您输入的日期有误,请重新输入")
elif month==3 and data>=21 or month==4 and data<=19:
print("您的星座是白羊座")
if month==3 and data>31:
print("您输入的日期有误,请重新输入")
elif month==4 and data>=20 or month==5 and data<=20:
print("您的星座是金牛座")
if month==4 and data>30 :
print("您输入的日期有误,请重新输入")
elif month==5 and data>=21 or month==6 and data<=21:
print("您的星座是双子座")
if month==5 and data>31 :
print("您输入的日期有误,请重新输入")
elif month==6 and data>=22 or month==7 and data<=22:
print("您的星座是巨蟹座")
if month==6 and data>30 :
print("您输入的日期有误,请重新输入")
elif month==7 and data>=23 or month==8 and data<=22:
print("您的星座是狮子座")
if month==7 and data>31:
print("您输入的日期有误,请重新输入")
elif month==8 and data>=23 or month==9 and data<=22:
print("您的星座是处女座")
if month==8 and data>31:
print("您输入的日期有误,请重新输入")
elif month==9 and data>=23 or month==10 and data<=22:
print("您的星座是天秤座")
if month==9 and data>30:
print("您输入的日期有误,请重新输入")
elif month==10 and data>=23 or month==11 and data<=21:
print("您的星座是天蝎座")
if month==10 and data>31:
print("您输入的日期有误,请重新输入")
elif month==11 and data>=22 or month==12 and data<=21:
print("您的星座是人马座")
if month==11 and data>30 :
print("您输入的日期有误,请重新输入")
elif month==12 and data>=22 or month==1 and data<=19:
print("您的星座是摩羯座")
if month==12 and data>31:
print("您输入的日期有误,请重新输入")
else:
if year<1000:
print("请输入不小于1000的年份")
else:
print("")