Python Date & Time

1. time module

import time

time.time() #The function time.time() returns the current system time in ticks since 12:00am, January 1, 1970(epoch).

time.asctime([tupletime]) #Accepts a time-tuple and returns a readable 24-character string such as 'Tue Dec 11 18:07:14 2008'.

time.localtime([secs]) #Accepts an instant expressed in seconds since the epoch and returns a time-tuple t with the local time (t.tm_isdst is 0 or 1, depending on whether DST applies to instant secs by local rules).

  

2. calendar module

import calendar

calendar.calendar(year,w=2,l=1,c=6)
#Returns a multiline string with a calendar for year 
#year formatted into three columns separated by c spaces. 
#w is the width in characters of each date; each line has length 21*w+18+2*c. 
#l is the number of lines for each week.

calendar.firstweekday( )
#Returns the current setting for the weekday that starts each week.
#By default, when calendar is first imported, this is 0, meaning Monday.

calendar.isleap(year)
#Returns True if year is a leap year; otherwise, False.

calendar.month(year,month,w=2,l=1)
#Returns a multiline string with a calendar for month month of year year, 
#one line per week plus two header lines. 
#w is the width in characters of each date; each line has length 7*w+6. 
#l is the number of lines for each week.

  

转载于:https://www.cnblogs.com/KennyRom/p/6293984.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值