- 在python中,如何使用strftime()格式化time.time()

我有一个epoch时间,它采用Seconds.PartOfSecond格式例如,1581218900.17436,如何在time.strftime()中使用?


import time


curTime = time.time()


# Following is not correct but gives idea what i'm looking for


formattedTime = time.strftime('%A %B %e, %Y %t', curTime) 



时间:

你需要把秒传给gmtime


import time


s=time.gmtime(1581218900.17436)


time.strftime("%Y-%m-%d %H:%M:%S", s)


'2020-02-09 03:28:20'


time.strftime('%A %B %e, %Y %t', s)


'Sunday February 9, 2020 t'



...