Python星座查询

目录:

代码

代码如下:

while True:
    d = input('请输入出生日期:')
    if d.isdigit():
        print('出生日期:', d)
        break
    else:
        print('输入的日期有误')
d = int(d)
for i in info:
    t = info[i].split('-')
    t1 = int(t[0])
    t2 = int(t[1])
    if d >= t1 and d <= t2:
        print('你的星座是:', i)
        break
    if d >= 1222 and d <= 1231:
        print('你的星座是:摩羯座')
        break
    #因为不支持0开头的数字所以使用了这种方法
    if d >=int('0101') and d <=int('0119'):
        print('你的星座是:摩羯座')
        break