Python 计算每个月天数

Python 3 教程 · 2019-02-12 15:28:11

以下代码通过导入 calendar 模块来计算每个月的天数:

实例(Python 3.0+)

#!/usr/bin/python3 # author by : www.codercto.com import calendar monthRange = calendar.monthrange(2016,9) print(monthRange)

执行以上代码输出结果为:

(3, 30)

输出的是一个元组,第一个元素是所查月份的第一天对应的是星期几(0-6),第二个元素是这个月的天数。以上实例输出的意思为 2016 年 9 月份的第一天是星期四,该月总共有 30 天。

点击查看所有 Python 3 教程 文章: https://codercto.com/courses/l/10.html

查看所有标签

Web Design Index by Content 3 (Web Design Index)

Web Design Index by Content 3 (Web Design Index)

Pepin Press (EDT) / Pepin Press / 2007-11 / USD 29.99

Would you like an overview of the state of the art in web design in a specific field? WEB DESIGN INDEX BY CONTENT provides exactly that: every year, 500 new designs are selected and grouped in more th......一起来看看 《Web Design Index by Content 3 (Web Design Index)》 这本书的介绍吧!

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具