import time print(dir(time)) # print components of "time" module print() print(time.time(), "\n") # print time as numeric value calculated from 1970, 1, 1, 00:00:00 t = time.ctime() # Sat Aug 7 01:19:22 2021 print(t) time.sleep(1) # pause for 1 seconds print(t.split(' ')[-1]) # print 'year' only print(t.split(' ')[-2].split(':')[-3]) # print "hour" only now = time.localtime() filename = "log_%02d%02d%02d_%02d-%02d-%02d.txt" % (now.tm_year, now.tm_mon, now.tm_mday, now.tm_hour, now.tm_min, now.tm_sec) print("\n", filename)
No comments:
Post a Comment