开发者社区> 问答> 正文

暂停一秒输出,并格式化当前时间。

暂停一秒输出,并格式化当前时间。

展开
收起
珍宝珠 2019-11-19 15:19:18 3154 0
1 条回答
写回答
取消 提交回答
  • 程序源代码:

    #!/usr/bin/python
    # -*- coding: UTF-8 -*-
    import time
    
    print time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))
    
    # 暂停一秒
    time.sleep(1)
    
    print time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))
    
    

    以上实例输出结果为:

    2015-10-21 17:48:40
    2015-10-21 17:48:41
    
    2019-11-19 15:20:06
    赞同 展开评论 打赏
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载