当前位置:网站首页>Example 010: time to show

Example 010: time to show

2022-07-05 08:22:00 Lazy smile

Topic content

####  example 010: Time to show 

# ** subject :** Pause output for one second , And format the current time .

Problem analysis

         Still use time() function

%Y  Year with century as a decimal number. year 
%m  Month as a decimal number [01,12]. month 
%d  Day of the month as a decimal number [01,31]. Japan 
%H  Hour (24-hour clock) as a decimal number [00,23]. when 
%M  Minute as a decimal number [00,59]. branch 
%S  Second as a decimal number [00,61]. second 
%z  Time zone offset from UTC.
%a  Locale's abbreviated weekday name.
%A  Locale's full weekday name.
%b  Locale's abbreviated month name.
%B  Locale's full month name.
%c  Locale's appropriate date and time representation.
%I  Hour (12-hour clock) as a decimal number [01,12].
%p  Locale's equivalent of either AM or PM.

Program

import time

for i in range(4):
    print(time.strftime('%H:%M:%S', time.localtime(time.time())))
    time.sleep(1)
import time

for i in range(4):
    print(time.strftime('%H:%M:%S'))
    time.sleep(1)

 

result :

 

 

原网站

版权声明
本文为[Lazy smile]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/186/202207050816109443.html