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

查看所有标签

Algorithms Sequential & Parallel

Algorithms Sequential & Parallel

Russ Miller、Laurence Boxer / Charles River Media / 2005-08-03 / USD 59.95

With multi-core processors replacing traditional processors and the movement to multiprocessor workstations and servers, parallel computing has moved from a specialty area to the core of computer scie......一起来看看 《Algorithms Sequential & Parallel》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

URL 编码/解码
URL 编码/解码

URL 编码/解码

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

在线 XML 格式化压缩工具