time时间模块(十八)

import time

# timestamp to struct
print(time.localtime())
print(time.time())

# time struct to timestamp
print(time.mktime(time.localtime()))

# struct to format string
print(time.strftime('%Y-%m-%d %X',time.localtime()))

# time sting to time struct
print(time.strptime('2019:2:26:08:01:30',
'%Y:%m:%d:%X'))

print(time.ctime())

print(time.asctime())


import datetime
# format time string
print(datetime.datetime.now())

 

time.struct_time(tm_year=2019, tm_mon=2, tm_mday=26, tm_hour=8, tm_min=50, tm_sec=19, tm_wday=1, tm_yday=57, tm_isdst=0)
1551142219.9133635
1551142219.0
2019-02-26 08:50:19
time.struct_time(tm_year=2019, tm_mon=2, tm_mday=26, tm_hour=8, tm_min=1, tm_sec=30, tm_wday=1, tm_yday=57, tm_isdst=-1)
Tue Feb 26 08:50:19 2019
Tue Feb 26 08:50:19 2019
2019-02-26 08:50:19.956367

 

posted @ 2019-02-26 08:40  狂奔~  阅读(118)  评论(0编辑  收藏  举报