题目是如图: 用 sys.argv 传入两个参数,第一是当前月份(例如输入3就是三月)第二个是过n月是某月(例如输入10,在三月的基础上过了10个月,是一月)。
我通过下面的代码 已经实现了。但是题目还要求是不能使用 if while 和 if。 菜鸟刚开始学习python,请各位大佬指点。
import sys
mouth = ['None', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'December', 'November']
cur = int(sys.argv[1])
nex = int(sys.argv[2])
i = nex
if nex > 12:
nex = nex%12 + cur
if nex >12:
nex = nex%12
else:
nex = cur + nex
print("It's currently {}, in {} months it will be {}.".format(mouth[cur],i,mouth[nex]))