十二生肖计算器2.7.6不会计算符号,行错误日期未定义。在编程时需要帮助,noob

时间:2014-12-04 03:25:37

标签: python python-2.7

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)

我需要一些帮助才能获得生成星座的代码。我是编码的菜鸟。保持这个错误。

追踪(最近一次通话):   文件“G:\ Python \ updatedZodiacSign.py”,第6行,in     d = date.today() NameError:未定义名称'date'

我需要一些帮助才能获得生成黄道带标志的代码。我是编码的小伙子。

1 个答案:

答案 0 :(得分:0)

把它放在顶部

from datetime import date

在从datetime模块导入日期对象之前,Python不知道日期对象是什么。