摘要: Time模块 Python中的Time 模块包含了以下内置函数,既有时间处理相的,也有转换时间格式的: 序号 函数及描述 1 time.altzone 返回格林威治西部的夏令时地区的偏移秒数。如果该地区在格林威治东部会返回负值(如西欧,包括...
Time模块
Python中的Time
模块包含了以下内置函数,既有时间处理相的,也有转换时间格式的:
序号
|
函数及描述
|
1
|
time.altzone |
2
|
time.asctime([tupletime]) |
3
|
time.clock( ) |
4
|
time.ctime([secs]) |
5
|
time.gmtime([secs]) |
6
|
time.localtime([secs]) |
7
|
time.mktime(tupletime) |
8
|
time.sleep(secs) |
9
|
time.strftime(fmt[,tupletime]) |
10
|
time.strptime(str,fmt='%a %b %d %H:%M:%S %Y') |
11
|
time.time( ) |
12
|
time.tzset() |
Time
模块包含了以下2个非常重要的属性:
序号
|
属性及描述
|
1
|
time.timezone |
2
|
time.tzname |
日历(Calendar
)模块
此模块的函数都是日历相关的,例如打印某月的字符月历。
星期一是默认的每周第一天,星期天是默认的最后一天。更改设置需调用calendar.setfirstweekday()
函数。模块包含了以下内置函数:
序号
|
函数及描述
|
1
|
calendar.calendar(year,w=2,l=1,c=6) |
2
|
calendar.firstweekday( ) |
3
|
calendar.isleap(year) |
4
|
calendar.leapdays(y1,y2) |
5
|
calendar.month(year,month,w=2,l=1) |
6
|
calendar.monthcalendar(year,month) |
7
|
calendar.monthrange(year,month) |
8
|
calendar.prcal(year,w=2,l=1,c=6) |
9
|
calendar.prmonth(year,month,w=2,l=1) |
10
|
calendar.setfirstweekday(weekday) |
11
|
calendar.timegm(tupletime) |