根据给定的年月日,以数字形式打印出日期

months = [
    'January',
    'February',
    'March',
    'April',
    'May',
    'June',
    'July',
    'August',
    'September',
    'October',
    'November',
    'December'
]
endings = ['st', 'nd', 'rd'] + 17 * ['th'] + ['st', 'nd', 'rd'] + 7 * ['th'] + ['st']

year = raw_input('Year: ')
month = raw_input('Month(1~12): ')
day = raw_input("Day(1~31): ")

month_number = int(month)
day_number = int(day)

month_name = months[month_number-1]
ordinal = day + endings[day_number-1]

print month_name + ' ' + ordinal + ', ' + year

Year: 2017
Month(1~12): 10
Day(1~31): 12
October 12th, 2017

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-08
猜你喜欢
  • 2022-12-23
  • 2021-10-15
  • 2021-08-05
  • 2021-06-15
  • 2022-12-23
  • 2018-03-03
  • 2021-11-11
相关资源
相似解决方案