《Python 基础教程》
1 months = [
2 'January',
3 'February',
4 'March',
5 'April',
6 'May',
7 'June',
8 'July',
9 'August',
10 'September',
11 'October',
12 'November',
13 'December'
14 ]
15
16 # print(month)
17
18 endings = ['st', 'nd', 'rd'] + 17 * ['th'] \
19 + ['st', 'nd', 'rd'] + 7 * ['th'] \
20 + ['st']
21
22 year = input("Year: ")
23 month = input("Month: ")
24 day = input("Day: ")
25
26 month_number = int(month)
27 day_number = int(day)
28
29 month_name = months[month_number-1]
30 ordinal = day + endings[day_number-1]
31
32 # print(1, 2, 3)
33 print(month_name + ' ' + ordinal + ', ' + year)
34
posted on 2013-05-12 14:05
unixfy 阅读(170)
评论(0) 编辑 收藏 引用