用python写月份的方法:
调用input方法输入月份,用if elif循环结构筛选符合条件的信息,然后再用print打印运行结果
month=int(input('Month:')) ifmonthin[3,4,5]: print('春季') elifmonthin[6,7,8]: print('夏季') elifmonthin[9,10,11]: print('秋季') elifmonthin[12,1,2]: print('冬季') else: print('请输入正确值:')
示例以及运行结果:
上一篇