Ubuntu 下用python 获取当前时间 的方法

来源:互联网 发布:高中数学矩阵与变换 编辑:程序博客网 时间:2024/06/05 23:54

>>> import time

>>> time.asctime()
'Mon Nov 26 16:49:07 2012'

 

如果想知道 time 模块的其他函数,可以用一下命令查询:(前提是已经执行了:import time语句)

>>> help(time)

结果:

    Functions:
   
    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

原创粉丝点击