#楼主的思路不错:把生日看做一个30/31进制的数,处理其来概念非常简单,而且不需要算生日在一年中的天数,也避免了润年的计算,很有创意。 #考虑到12/31的问题,可以做个优化,具体实现如下(在python2.3.2下测试通过): def get_constellation(month, date): dates = (21, 20, 21, 21, 22, 22, 23, 24, 24, 24, 23, 22) constellations = ("摩羯", "水瓶", "双鱼", "白羊", "金牛", "双子", "巨蟹", "狮子", "处女", "天秤", "天蝎", "射手", "摩羯") if date < dates[month-1]: return constellations[month-1] else: return constellations[month] print get_constellation(2, 27)