Calculation constellation
来源:互联网 发布:linux如何退出top命令 编辑:程序博客网 时间:2024/05/18 09:55
# -*- coding: cp936 -*-
import os, time, string
def isContainLetters(birthday):
notrans = string.maketrans('', '')
letterset = string.letters
return len(letterset) != len(letterset.translate(notrans, birthday))
def chinese_zodiac(year):
sets = ['猴', '鸡', '狗', '猪', '鼠', '牛', '虎', '兔', '龙', '蛇', '马', '羊']
return sets[year%12]
def constellation(month, day):
sets = ('摩羯座','水瓶座','双鱼座','白羊座','金牛座','双子座','巨蟹座','狮子座','处女座','天秤座','天蝎座','射手座')
dates = ((1,20),(2,19),(3,21),(4,21),(5,21),(6,22),(7,23),(8,23),(9,23),(10,23),(11,23),(12,23))
s = filter(lambda y: y <= (month, day), dates)
return sets[len(list(s)) % 12]
def constellation2(month, day):
zodiac_map = {
'白羊座':[(3, 21), (4, 20)],
'金牛座':[(4, 21), (5, 20)],
'双子座':[(5, 21), (6, 21)],
'巨蟹座':[(6, 22), (7, 22)],
'狮子座':[(7, 23), (8, 22)],
'处女座':[(8, 23), (9, 22)],
'天秤座':[(9, 23), (10, 22)],
'天蝎座':[(10, 23), (11, 21)],
'射手座':[(11, 23), (12, 22)],
'水瓶座':[(1, 20), (2, 18)],
'双鱼座':[(2, 19), (3, 20)]
}
for c, d in zodiac_map.items():
if d[0] <= (month, day) <= d[1]:
return c
if (month, day) >= (12, 23) or (month, day) <= (1, 19):
return '摩羯座'
if __name__ == '__main__':
mark = 'go'
while 'exit' != mark:
while True:
Birthday = raw_input("Please input your birthday in the form. Year/Month/Day: ")
if '' == Birthday:
print('The input value is empty, please resume input! \n')
continue
if isContainLetters(Birthday):
print('The input value is letters, please resume input! \n')
continue
if 2 > Birthday.count('/'):
print('The value of the input of format is wrong, please resume input! \n')
continue
year = int(Birthday.split('/')[0])
month = int(Birthday.split('/')[1])
day = int(Birthday.split('/')[2])
currentTime = time.strftime('%Y-%m-%d', time.localtime(time.time()))
currentTime2 = time.strftime('%Y-%m-%d-%H-%M-%S', time.localtime(time.time()))
currentYear = int(currentTime.split('-')[0])
currentMonth = int(currentTime.split('-')[1])
currentDay = int(currentTime.split('-')[2])
if year > currentYear:
print('The specified year has not yet born, please resume input! \n')
continue
if month > 12:
print('The specified month has not yet born, please resume input! \n')
continue
if month > currentMonth and year == currentYear:
print('The specified month has not yet born, please resume input! \n')
continue
if day > currentDay and month == currentMonth and year == currentYear:
print('The specified day has not yet born, please resume input! \n')
continue
break
person_zodiac = chinese_zodiac(year)
person_constellation = constellation2(month, day)
print('The current time is: %s. \n' % currentTime2)
print("Your chinese zodiac is: %s, \n and your constellation is: %s ." %(person_zodiac, person_constellation))
mark = raw_input('is exit?')
import os, time, string
def isContainLetters(birthday):
notrans = string.maketrans('', '')
letterset = string.letters
return len(letterset) != len(letterset.translate(notrans, birthday))
def chinese_zodiac(year):
sets = ['猴', '鸡', '狗', '猪', '鼠', '牛', '虎', '兔', '龙', '蛇', '马', '羊']
return sets[year%12]
def constellation(month, day):
sets = ('摩羯座','水瓶座','双鱼座','白羊座','金牛座','双子座','巨蟹座','狮子座','处女座','天秤座','天蝎座','射手座')
dates = ((1,20),(2,19),(3,21),(4,21),(5,21),(6,22),(7,23),(8,23),(9,23),(10,23),(11,23),(12,23))
s = filter(lambda y: y <= (month, day), dates)
return sets[len(list(s)) % 12]
def constellation2(month, day):
zodiac_map = {
'白羊座':[(3, 21), (4, 20)],
'金牛座':[(4, 21), (5, 20)],
'双子座':[(5, 21), (6, 21)],
'巨蟹座':[(6, 22), (7, 22)],
'狮子座':[(7, 23), (8, 22)],
'处女座':[(8, 23), (9, 22)],
'天秤座':[(9, 23), (10, 22)],
'天蝎座':[(10, 23), (11, 21)],
'射手座':[(11, 23), (12, 22)],
'水瓶座':[(1, 20), (2, 18)],
'双鱼座':[(2, 19), (3, 20)]
}
for c, d in zodiac_map.items():
if d[0] <= (month, day) <= d[1]:
return c
if (month, day) >= (12, 23) or (month, day) <= (1, 19):
return '摩羯座'
if __name__ == '__main__':
mark = 'go'
while 'exit' != mark:
while True:
Birthday = raw_input("Please input your birthday in the form. Year/Month/Day: ")
if '' == Birthday:
print('The input value is empty, please resume input! \n')
continue
if isContainLetters(Birthday):
print('The input value is letters, please resume input! \n')
continue
if 2 > Birthday.count('/'):
print('The value of the input of format is wrong, please resume input! \n')
continue
year = int(Birthday.split('/')[0])
month = int(Birthday.split('/')[1])
day = int(Birthday.split('/')[2])
currentTime = time.strftime('%Y-%m-%d', time.localtime(time.time()))
currentTime2 = time.strftime('%Y-%m-%d-%H-%M-%S', time.localtime(time.time()))
currentYear = int(currentTime.split('-')[0])
currentMonth = int(currentTime.split('-')[1])
currentDay = int(currentTime.split('-')[2])
if year > currentYear:
print('The specified year has not yet born, please resume input! \n')
continue
if month > 12:
print('The specified month has not yet born, please resume input! \n')
continue
if month > currentMonth and year == currentYear:
print('The specified month has not yet born, please resume input! \n')
continue
if day > currentDay and month == currentMonth and year == currentYear:
print('The specified day has not yet born, please resume input! \n')
continue
break
person_zodiac = chinese_zodiac(year)
person_constellation = constellation2(month, day)
print('The current time is: %s. \n' % currentTime2)
print("Your chinese zodiac is: %s, \n and your constellation is: %s ." %(person_zodiac, person_constellation))
mark = raw_input('is exit?')
- Calculation constellation
- Calculation
- CF618C - Constellation
- Constellation CodeForces
- constellation音乐玄机
- Funny 12 constellation
- LTE:Constellation Mapping
- codeforces 618C. Constellation
- CodeForces 618C Constellation
- Codeforces 618C Constellation
- Codeforces 618C Constellation
- CodeForces 618C 、Constellation
- calculation error
- Histogram Calculation
- Ternary Calculation
- Simple Calculation
- Simple Calculation
- Ternary Calculation
- SRTM DEM hgt格式转成GRID格式的问题解决
- vim设置方法集锦
- CJLibrary
- 西南石油大学csdn计科讲坛
- Functions for Working with Objects matlab
- Calculation constellation
- struts2中action的3种实现方式
- Sunboy_2050的专栏
- html id与name区别
- request.getScheme()
- oracle 数据库表空间、用户、权限的创建与删除
- (七)Struts2的struts.xml的配置细节
- 程序员每天该做的事
- 页面图片浮动左右滑动效果实现案例