Python中对日期的较量争论能够应用calendar模块。
完成代码以下:
#!/usr/bin/python3 import calendar year = input("请输出年份:") month = input("请输出月份:") year = int(year) month = int(month) monthRange = calendar.monthrange(year,month) print("%d年%d月有%d天" % (year,month,monthRange[1]))
成果以下:
更多Python相干技巧文章,请拜访Python教程栏目进行学习!
以上就是用python怎样编写输出月份并输入月份天数的具体内容,更多请存眷资源魔其它相干文章!
标签: python教程 python编程 python使用问题 用python编写输入月份并输出月份天数
版权声明:除非特别标注,否则均为本站原创文章,转载时请以链接形式注明文章出处。
抱歉,评论功能暂时关闭!