這篇文章主要講解了Python中time模塊的學習方法,內(nèi)容清晰明了,對此有興趣的小伙伴可以學習一下,相信大家閱讀完之后會有幫助。
time 模塊主要包含各種提供日期、時間功能的類和函數(shù)。該模塊既提供了把日期、時間格式化為字符串的功能,也提供了從字符串恢復日期、時間的功能。
在 Python 的交互式解釋器中先導入 time 模塊,然后輸入 [e for e in dir(time) if not e.startswith('_')] 命令,即可看到該模塊所包含的全部屬性和函數(shù):
>>> [e for e in dir(time) if not e.startswith('_')] ['altzone', 'asctime', 'clock', 'ctime', 'daylight', 'get_clock_info', 'gmtime', 'localtime', 'mktime', 'monotonic', 'perf_counter', 'process_time', 'sleep', 'strftime', 'strptime', 'struct_time', 'time', 'timezone', 'tzname']