python的时间模块似乎有点杂乱无章.例如,以下是docstring中的方法列表:
time() -- return current time in seconds since the Epoch as a float clock() -- return CPU time since process start as a float sleep() -- delay for a number of seconds given as a float gmtime() -- convert seconds since Epoch to UTC tuple localtime() -- convert seconds since Epoch to local time tuple asctime() -- convert time tuple to string ctime() -- convert time in seconds to string mktime() -- convert local time tuple to seconds since Epoch strftime() -- convert time tuple to string according to format specification strptime() -- parse string to time tuple according to format specification tzset() -- change the local timezone
查看localtime()及其反mktime(),为什么gmtime()没有反转?
奖金问题:你怎么称呼这个方法?你会如何实现它?
实际上有一个反函数,但由于一些奇怪的原因,它在日历模块中:calendar.timegm().我列出了这个答案中的功能.