Python学习笔记(14)常用模块

1. time

time.time()

>>> time.time()
1525574050.721484

time.sleep(2)

 time.localtime()

>>> time.localtime()
time.struct_time(tm_year=2018, tm_mon=5, tm_mday=6, tm_hour=10, tm_min=36, tm_sec=19, tm_wday=6, tm_yday=126, tm_isdst=0)

 time.strftime()

>>> time.strftime('%Y-%m-%d %H:%M:%S %A', time.localtime())

'2018-05-06 10:39:50 Sunday'

timt.ctime()

>>> time.ctime()

'Sun May 6 10:48:28 2018'

time.clock()

>>> time.clock()

6088.2022025323

 time.strptime()

 a = time.strptime('2018-03-24', '%Y-%m-%d')

>>> a.tm_year

2018

>>> a.tm_mon

3
>>> a.tm_mday

24

猜你喜欢

转载自www.cnblogs.com/thyh/p/8997669.html