您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

用python怎么编写输入月份并输出月份天数

2025/10/31 14:43:25发布31次查看
python中对日期的计算可以使用calendar模块。
实现代码如下:
#!/usr/bin/python3import calendaryear = 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怎么编写输入月份并输出月份天数的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product