如果有 months = "Jan.Feb.Mar.Apr.May.Jun.Jul.Aug.Sep.Oct.Nov.Dec.",编写程序,用户输入月份数字,输出月份缩写
时间: 2023-05-28 21:06:56 浏览: 394
Java简单程序 键入数字输出相应的月份的英文
months = "Jan.Feb.Mar.Apr.May.Jun.Jul.Aug.Sep.Oct.Nov.Dec."
month_num = int(input("请输入月份数字:"))
if month_num >= 1 and month_num <= 12:
start_index = (month_num - 1) * 4
end_index = start_index + 3
month_abbr = months[start_index:end_index+1]
print("月份缩写为:", month_abbr)
else:
print("输入的月份数字不正确")
阅读全文