python_日历 list_5

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python_日历 list_5相关的知识,希望对你有一定的参考价值。

>>> import datetime
>>> Today=datetime.date.today()
>>> Today
datetime.date(2017, 5, 24)
>>> Today-datetime.date(Today.year,1,1)+datetime.timedelta(days=1)
datetime.timedelta(144)
>>> datetime.date(Today.year,1,1)
datetime.date(2017, 1, 1)
>>> datetime.timedelta(days=1)
datetime.timedelta(1)
>>> Today.timetuple().tm_yday
144
>>> Today.replace(year=2013)
datetime.date(2013, 5, 24)
>>> Today.replace(month=1)
datetime.date(2017, 1, 24)
>>> now=datetime.datetime.now()
>>> now
datetime.datetime(2017, 5, 24, 12, 44, 51, 448321)
>>> now.replace(second=30)
datetime.datetime(2017, 5, 24, 12, 44, 30, 448321)
>>> now+datetime.timedelta(days=5)
datetime.datetime(2017, 5, 29, 12, 44, 51, 448321)

>>> now+datetime.timedelta(weeks=-5)
datetime.datetime(2017, 4, 19, 12, 44, 51, 448321)

 

>>> import calendar
>>> print(calendar.calendar(2017))
2017

January February March
Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su
1 1 2 3 4 5 1 2 3 4 5
2 3 4 5 6 7 8 6 7 8 9 10 11 12 6 7 8 9 10 11 12
9 10 11 12 13 14 15 13 14 15 16 17 18 19 13 14 15 16 17 18 19
16 17 18 19 20 21 22 20 21 22 23 24 25 26 20 21 22 23 24 25 26
23 24 25 26 27 28 29 27 28 27 28 29 30 31
30 31

April May June
Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su
1 2 1 2 3 4 5 6 7 1 2 3 4
3 4 5 6 7 8 9 8 9 10 11 12 13 14 5 6 7 8 9 10 11
10 11 12 13 14 15 16 15 16 17 18 19 20 21 12 13 14 15 16 17 18
17 18 19 20 21 22 23 22 23 24 25 26 27 28 19 20 21 22 23 24 25
24 25 26 27 28 29 30 29 30 31 26 27 28 29 30

July August September
Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su
1 2 1 2 3 4 5 6 1 2 3
3 4 5 6 7 8 9 7 8 9 10 11 12 13 4 5 6 7 8 9 10
10 11 12 13 14 15 16 14 15 16 17 18 19 20 11 12 13 14 15 16 17
17 18 19 20 21 22 23 21 22 23 24 25 26 27 18 19 20 21 22 23 24
24 25 26 27 28 29 30 28 29 30 31 25 26 27 28 29 30
31

October November December
Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su
1 1 2 3 4 5 1 2 3
2 3 4 5 6 7 8 6 7 8 9 10 11 12 4 5 6 7 8 9 10
9 10 11 12 13 14 15 13 14 15 16 17 18 19 11 12 13 14 15 16 17
16 17 18 19 20 21 22 20 21 22 23 24 25 26 18 19 20 21 22 23 24
23 24 25 26 27 28 29 27 28 29 30 25 26 27 28 29 30 31
30 31

>>> print(calendar.month(2016,4))
April 2016
Mo Tu We Th Fr Sa Su
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30

>>> calendar.isleap(2016)
True
>>> calendar.weekday(2017,5,24)
2

技术分享































































以上是关于python_日历 list_5的主要内容,如果未能解决你的问题,请参考以下文章

请教python+tkinter如何实现下拉日历

[oldboy-django][5python基础][内置函数]zip

翻译:《实用的Python编程》04_00_Overview

Python学习笔记六:集合

python学习记录三

PyQt 显示来自 opencv 的视频流