python-分享篇-根据出生日期判断你的星座&出生日期判断生肖

根据出生日期判断你的星座

sdate=[20,19,21,20,21,22,23,23,23,24,23,22]     # 星座判断列表
conts =['摩羯座','水瓶座','双鱼座','白羊座','金牛座','双子座','巨蟹座','狮子座','处女座','天秤座','天蝎座','射手座','摩羯座']
signs=['♑','♒','♓','♈','♉','♊','♋','♌','♍','♎','♏','♐','♑']

# 输入生日,输出星座
birth = input('请输入你的出生年月日,格式为:2001-02-21\n').strip(' ')
cbir=birth.split('-')    # 分割年月日到列表
cmonth=str(cbir[1])      # 提取月数据
cdate=str(cbir[2])       # 提取日数据
def sign(cmonth,cdate):  #  判断星座函数
    if int(cdate)<sdate[int(cmonth)-1]:   # 如果日数据早于对应月列表中对应的日期
        print(conts[int(cmonth)-1])       # 直接输出星座列表对应月对应的星座
        print(signs[int(cmonth)-1])       # 直接输出星座列表对应月对应的星座
    else:
        print(conts[int(cmonth)])         # 否则输出星座列表下一月对应的星座
        print(signs[int(cmonth)])         # 否则输出星座列表下一月对应的星座        
sign(cmonth,cdate)      # 调用星座判断程序

效果:
在这里插入图片描述

出生日期判断生肖

import math
lunar = '申酉戌亥子丑寅卯辰巳午未'
zodiac = '猴鸡狗猪鼠牛虎兔龙蛇马羊'
ztime = ['1936(1.24)', '1937(2.11)', '1938(1.31)', '1939(2.19)', '1940(2.08)', '1941(1.27)', '1942(2.15)', '1943(2.05)', '1944(1.25)', '1945(2.13)', '1946(2.02)', '1947(1.22)', '1948(2.10)', '1949(1.29)', '1950(2.17)', '1951(2.06)', '1952(1.27)', '1953(2.14)', '1954(2.03)', '1955(1.24)', '1956(2.12)', '1957(1.31)', '1958(2.18)', '1959(2.08)', '1960(1.28)', '1961(2.15)', '1962(2.05)', '1963(1.25)', '1964(2.13)', '1965(2.02)', '1966(1.21)', '1967(2.09)', '1968(1.30)', '1969(2.17)', '1970(2.06)', '1971(1.27)', '1972(2.15)', '1973(2.03)', '1974(1.23)', '1975(2.11)', '1976(1.31)', '1977(2.18)', '1978(2.07)', '1979(1.28)', '1980(2.16)', '1981(2.05)', '1982(1.25)', '1983(2.13)', '1984(2.2)', '1985(2.20)', '1986(2.09)', '1987(1.29)', '1988(2.17)', '1989(2.06)', '1990(1.27)', '1991(2.15)', '1992(2.04)', '1993(1.23)', '1994(2.10)', '1995(1.31)', '1996(2.19)', '1997(2.07)', '1998(1.28)', '1999(2.16)', '2000(2.05)', '2001(1.24)', '2002(2.12)', '2003(2.01)', '2004(1.22)', '2005(2.09)', '2006(1.29)', '2007(2.18)', '2008(2.07)', '2009(1.26)', '2010(2.14)', '2011(2.03)', '2012(1.23)', '2013(2.10)', '2014(2.04)', '2015(2.19)', '2016(2.08)', '2017(1.28)', '2018(2.16)', '2019(2.05)', '2020(1.25)']
mdate = ''
ral = ['鼠',1984]
shop = '100000056303'
inside = ''
birth = input('请输入你的出生年月日,格式为:2001-02-21\n')
cbir = birth.split('-')
cyear = cbir[0]
cmonth = cbir[1]
cdate = cbir[2]
for item in ztime:
    if item[:4] == cyear:
        mdate = item[4:].strip(' ').strip('(').strip(')')
ctime = str(cmonth) + str(cdate)
ndate = mdate.split('.')
smonth = ndate[0]
sdate = ndate[1]
stime = str(smonth) + str(sdate)
if int(ctime) < int(stime):
    cyear = int(cyear) - 1
rem = int(cyear) % 12
print('要查询的属相是:' + zodiac[rem] + '\n属相对应的年份是:' + lunar[rem] + '年')

效果:

在这里插入图片描述

  • 9
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

fo安方

觉得俺的文章还行,感谢打赏,爱

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值