0
Year = input("year of birth:")
Month = input("month of birth:")
Day = input("day of birth:")
Date_of_Birth = (str(Day) + "/" + str(Month) + "/" + str(Year))
print('Your Date of Birth is ' + Date_of_Birth)
d = date.today()
y = d.year
age = y - int(Year)
print('Your age is ' + str(age))
if ((int(Month)==12 and int(Day) >= 22)or(int(Month)==1 and int(Day)<= 19)):
Signo_Zodiacal = ("\n Capricorn")
elif ((int(Month)==1 and int(Day) >= 20)or(int(Month)==2 and int(Day)<= 17)):
zodiac_sign = ("\n aquarium")
elif ((int(Month)==2 and int(Day) >= 18)or(int(Month)==3 and int(Day)<= 19)):
zodiac_sign = ("\n Pices")
elif ((int(Month)==3 and int(Day) >= 20)or(int(Month)==4 and int(Day)<= 19)):
zodiac_sign = ("\n Aries")
elif ((int(Month)==4 and int(Day) >= 20)or(int(Month)==5 and int(Day)<= 20)):
zodiac_sign = ("\n Taurus")
elif ((int(Month)==5 and int(Day) >= 21)or(int(Month)==6 and int(Day)<= 20)):
zodiac_sign = ("\n Gemini")
elif ((int(Month)==6 and int(Day) >= 21)or(int(Month)==7 and int(Day)<= 22)):
zodiac_sign = ("\n Cancer")
elif ((int(Month)==7 and int(Day) >= 23)or(int(Month)==8 and int(Day)<= 22)):
zodiac_sign = ("\n Leo")
elif ((int(Month)==8 and int(Day) >= 23)or(int(Month)==9 and int(Day)<= 22)):
Signo_Zodiacal = ("\n Virgo")
elif ((int(Month)==9 and int(Day) >= 23)or(int(Month)==10 and int(Day)<= 22)):
zodiac_sign = ("\n Libra")
elif ((int(Month)==10 and int(Day) >= 23)or(int(Month)==11 and int(Day)<= 21)):
zodiac_sign = ("\n Scorpio")
elif ((int(Month)==11 and int(Day) >= 22)or(int(Month)==12 and int(Day)<= 21)):
zodiac_sign = ("\n Sagittarius")
print(zodiac_sign)
我需要一些帮助来获取代码来调出星座。我是编码的noob。请记住这个错误。十二生肖计算器2.7.6不会计算符号,线路错误日期未定义。在编程时需要帮助,noob
回溯(最近最后调用): 文件 “G:\的Python \ updatedZodiacSign.py”,第6行,在 d = date.today()NameError :名称 '日期' 没有定义
我需要一些帮助才能获取代码来调出十二宫星座。我是编码的小老鼠。
谢谢你的工作!感谢你的帮助。就像我说的,我是新手,我的老师就像每个人都应该知道的那样贯穿整个过程。请你为我贬低它。我在“编程逻辑介绍”中。 – pacman 2014-12-04 03:34:55
当你调用date.today()时,python认为pacman想要在对象'date'上调用today()方法。但默认情况下,python不知道日期是什么。有一些代码定义了date对象在模块中的作用(这只是另一个python文件),称为datetime。 Datetime是Python自带的标准模块之一。有很多标准模块,请参阅https://docs.python.org/2/library/。他们做各种你不需要担心的事情。当你从datetime导入日期时,你告诉python使用标准库日期时间模块中的对象日期。 – 2014-12-04 03:45:21
有datetime标准模块的文档btw https://docs.python.org/2/library/datetime.html – 2014-12-04 03:47:36