求助:关于python语句的结果表达形式!3)索引例子:编写日期索引,显示结果为月份 日期,年份.months=['1m','2m','3m','4m','5m','6m','7m','8m','9m','10m','11m','12m']endings=['st','nd','rd']+17*['th']\+['st','nd','rd']+7*[
来源:学生作业帮助网 编辑:作业帮 时间:2024/09/02 23:38:11
![求助:关于python语句的结果表达形式!3)索引例子:编写日期索引,显示结果为月份 日期,年份.months=['1m','2m','3m','4m','5m','6m','7m','8m','9m','10m','11m','12m']endings=['st','nd','rd']+17*['th']\+['st','nd','rd']+7*[](/uploads/image/z/10133583-15-3.jpg?t=%E6%B1%82%E5%8A%A9%EF%BC%9A%E5%85%B3%E4%BA%8Epython%E8%AF%AD%E5%8F%A5%E7%9A%84%E7%BB%93%E6%9E%9C%E8%A1%A8%E8%BE%BE%E5%BD%A2%E5%BC%8F%213%EF%BC%89%E7%B4%A2%E5%BC%95%E4%BE%8B%E5%AD%90%EF%BC%9A%E7%BC%96%E5%86%99%E6%97%A5%E6%9C%9F%E7%B4%A2%E5%BC%95%2C%E6%98%BE%E7%A4%BA%E7%BB%93%E6%9E%9C%E4%B8%BA%E6%9C%88%E4%BB%BD+%E6%97%A5%E6%9C%9F%2C%E5%B9%B4%E4%BB%BD.months%3D%5B%271m%27%2C%272m%27%2C%273m%27%2C%274m%27%2C%275m%27%2C%276m%27%2C%277m%27%2C%278m%27%2C%279m%27%2C%2710m%27%2C%2711m%27%2C%2712m%27%5Dendings%3D%5B%27st%27%2C%27nd%27%2C%27rd%27%5D%2B17%2A%5B%27th%27%5D%5C%2B%5B%27st%27%2C%27nd%27%2C%27rd%27%5D%2B7%2A%5B)
求助:关于python语句的结果表达形式!3)索引例子:编写日期索引,显示结果为月份 日期,年份.months=['1m','2m','3m','4m','5m','6m','7m','8m','9m','10m','11m','12m']endings=['st','nd','rd']+17*['th']\+['st','nd','rd']+7*[
求助:关于python语句的结果表达形式!
3)索引例子:
编写日期索引,显示结果为月份 日期,年份.
months=['1m','2m','3m','4m','5m','6m','7m','8m','9m','10m','11m','12m']
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]
day_name=day+endings[day_number-1]
print month_name + '_'+day_name+'_,' +year
显示结果为:
year:2011
month(1~12):11
day(1~31):12
11m 12th ,2011
小白我唯一不太懂的地方就是print month_name + '_'+day_name+'_,' +year这行中, '_'+day_name+'_,'为啥加了那么多的单引号,而且day_name旁边还添加了+号,我尝试过去掉旁边的加号,但是显示出来的结果却是“11m day_name ,2011"
求各位大侠帮忙解答~~~!
求助:关于python语句的结果表达形式!3)索引例子:编写日期索引,显示结果为月份 日期,年份.months=['1m','2m','3m','4m','5m','6m','7m','8m','9m','10m','11m','12m']endings=['st','nd','rd']+17*['th']\+['st','nd','rd']+7*[
month_name + '_'+day_name+'_,' +year:采用+是将三个字符串和'_'一起连接成一个字符串.