• 技术文章 >Python技术 >Python基础教程

    python time.ctime()如何做时间加减法

    小妮浅浅小妮浅浅2021-08-10 09:35:49原创9695

    1、语法

    time.ctime([ sec ])

    2、参数,sec,要转换为字符串时间的秒数。

    3、时间加减法需要将加减的参数需全部换成秒。

    实例

    import time
    #获取当前时间
    print(time.ctime())
    #获取当前时间
    later=time.time()+86400
    #计算一天后的时间
    print(time.ctime(later))
    #计算20秒后的时间
    print(time.ctime(time.time()+20))

    以上就是python time.ctime()做时间加减法的方法,希望对大家有所帮助。更多Python学习指路:python基础教程

    本文教程操作环境:windows7系统、Python 3.9.1,DELL G3电脑。

    专题推荐:python timectime
    品易云
    上一篇:python time库有哪些时钟 下一篇:python strftime获取当前时间

    相关文章推荐

    • Python中__slots__限制属性• Python测试前置操作的方法• Python unittest有哪些使用方法• python动态规划算法的使用过程• python线程安全的介绍及解决方法• python迭代器协议支持的两种方法• python中chardet库的安装和导入• python chardet库的函数用法• python中使用动量交易策略• python动量交易策略的四个步骤

    全部评论我要评论

    © 2021 Python学习网 苏ICP备2021003149号-1

  • 取消发布评论
  • 

    Python学习网