python 得到几个月的日子
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 得到几个月的日子相关的知识,希望对你有一定的参考价值。
#!/usr/bin/env python
# encoding: utf-8
#################################################################
# refer: http://cmcenroe.me/2014/12/05/days-in-month-formula.html
#################################################################
import math
def get_days_of_month(x):
return int(28 + (x + math.floor(x / 8)) % 2 + 2 % x + 2 * math.floor(1 / x))
if __name__ == '__main__':
months = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
days = [get_days_of_month(m) for m in months]
print days
以上是关于python 得到几个月的日子的主要内容,如果未能解决你的问题,请参考以下文章