python五十五課 calendar模組

2022-06-19 13:15:14 字數 1109 閱讀 8516

4.calendar模組:

構造:calendar(year,[w=2,l=1,c=6]):返回year年的完整的日曆資訊物件

和閏年相關的函式如下:

isleap(year):判斷year是否是閏年

返回true,說明是閏年

返回false,說明不是閏年

leapdays(y1,y2):返回[y1,y2)之間的閏年個數

import

calendar

'''演示calendar(日曆):模組的使用

'''#

構造:calendar(year,[w=2,l=1,c=6]):返回year年的完整的日曆資訊物件

c=calendar.calendar(2018)

print

(c)print

(type(c))

'''關於閏年的一些方法:

issleap(year):判斷year是否是閏年

返回true,說明是閏年

返回false,說明不是閏年

'''print(calendar.isleap(2004)) #

true 是閏年

print(calendar.isleap(2018)) #

false 不是閏年 是平年

'''leapdays(y1,y2):返回[y1,y2]之間的閏年個數

'''print(calendar.leapdays(2010,2018))

#month(year,month):返回year年month月的日曆資訊物件

print(calendar.month(2018,12))

'''monthrange(year,month):返回乙個元祖物件,一共有兩個元素

第乙個元素儲存的是1號是本週的第幾天,

第二個元素儲存的是本月一共有幾天

'''print(calendar.monthrange(2018,12))

#timegm(tp):將時間元組物件轉換為時間戳物件返回

ts=calendar.timegm((2018,11,19,16,10,35))

print(ts)

返回目錄

第五十五課 經典問題解析四

1 new和malloc 1 new關鍵字是c 的一部分 malloc是c庫提供的函式 2 new是以具體型別為單位分配記憶體 malloc是以位元組為單位分配記憶體 3 new在申請記憶體空間時可進行初始化 malloc僅根據需要申請定量的記憶體空間 4 new在所有c 編譯器中都被支援 mall...

安全駕駛 心病 五十五

在高速上,後面有輛寶馬使勁朝我閃燈,希望我給他讓路,我就是不讓他,而且他超我,我就提速,就是不讓他超 這樣折騰了好久!為什麼有賭氣心理呢?主要原因就是心理不平衡,你開好車就牛b 啊?這種心理持續了好久。我相信,很多人有過類似心理,這其實也是安全隱患,消除這種心理的根本,還是需要親身去經歷一下。我以前...

程式設計第五十五天

c algorithm標頭檔案中find演算法 include iostream include algorithm using namespace std void printelem int elem int main int i find ia,ia 7,9 在整個陣列中查詢元素 9 int ...