#要求你输入年、月(数1-12)、日(数1-31),再使用相应的月份名称将其打印出来。
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=input('Year:')
month=int(input('Month(1-12):'))
day=input('Day(1-31):')
day_number=int(day)
print(months[month-1]+' '+day+endings[day_number-1]+','+year)
input("press<enter>")
1. \斜杠:文末加\,\和回车键将被转义。
2. 1-31日的英文缩写:1st,2nd,3rd,4th,5th.......20th,21st,22nd,23rd,24th....30th,31st
3. input():将输入的值以文本或字符串的形式返回。
4. int():将字符串转换为整数
5. + :只能对类型相同的进行相加,str类型+int类型的是不成立的。
6. 序列的乘法运算:重复该序列,并创建新的序列。