当前位置:网站首页>实例010:给人看的时间

实例010:给人看的时间

2022-07-05 08:16:00 懒笑翻

题目内容

#### 实例010:给人看的时间

# **题目:**暂停一秒输出,并格式化当前时间。

问题分析

        还是用到time()函数

%Y  Year with century as a decimal number.年
%m  Month as a decimal number [01,12].月
%d  Day of the month as a decimal number [01,31].日
%H  Hour (24-hour clock) as a decimal number [00,23].时
%M  Minute as a decimal number [00,59].分
%S  Second as a decimal number [00,61].秒
%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.

程序

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)

 

结果:

 

 

原网站

版权声明
本文为[懒笑翻]所创,转载请带上原文链接,感谢
https://lanxf.blog.csdn.net/article/details/125609789