Home  >  Article  >  Backend Development  >  python获得一个月有多少天的方法

python获得一个月有多少天的方法

WBOY
WBOYOriginal
2016-06-10 15:10:471998browse

本文实例讲述了python获得一个月有多少天的方法。分享给大家供大家参考。具体分析如下:

在python的datetime模块中没有一个月有多少天的方法,但是可以使用calendar模块获得。

如下代码:

import calendar
monthRange = calendar.monthrange(2013,6)
print monthRange

输出:

(5,30)

输出的是一个元组,第一个元素是月份(0-11),第二个元素是这个月的天数。

希望本文所述对大家的Python程序设计有所帮助。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn