Access Real Time on Computer

This question already has an answer here:

  • How to get current time in Python? 27 answers

  • import time
    
    print time.strftime('%I:%M:%S %p %Z')
    

    For me, prints 12:21:51 PM EDT

    Edit: Just want to clarify the place holders.

    %I = Hour (12-hour clock) as a decimal number [01,12].
    %M = Minute as a decimal number [00,59].
    %S = Second as a decimal number [00,61].
    %p = Locale's equivalent of either AM or PM.
    %Z = Time zone name (no characters if no time zone exists).


    time.ctime() will do the job. time.time() will give you the time in seconds, just brows through the module time

    链接地址: http://www.djcxy.com/p/40910.html

    上一篇: 在Python中的程序中打印两个点之间的时间

    下一篇: 在计算机上访问实时