教程集 www.jiaochengji.com
教程集 >  Python编程  >  Python入门  >  正文 如何用python写月份

如何用python写月份

发布时间:2021-03-19   编辑:jiaochengji.com
教程集为您提供如何用python写月份等资源,欢迎您收藏本站,我们将为您提供最新的如何用python写月份资源

用python写月份的方法:

调用input方法输入月份,用if elif循环结构筛选符合条件的信息,然后再用print打印运行结果

month = int(input('Month:'))
  if month in [3,4,5]:
      print('春季')
  elif month in [6,7,8]:
      print('夏季')
  elif month in [9,10,11]:
      print('秋季')
  elif month in [12,1,2]:
      print('冬季')
  else:
      print('请输入正确值:')

示例以及运行结果:

您可能感兴趣的文章:
用python怎么编写输入月份并输出月份天数
如何用python写月份
python如何获取星期几
Python 2.x和Python 3.x,初学者应如何选择?
如何用php获取指定月份月初和月末的时间戳
PHP Date()函数详解
jquery UI 1.72 之datepicker
详细讲解PHP的日期时间函数date()
生成某时间段内的从开始月份到结束月份的月份数组的代码
jQuery 联动日历实现代码

[关闭]
~ ~