zoukankan      html  css  js  c++  java
  • python 时间模块

    import time,datetime

    # time.timezone()#获取时区,显示为秒
    # time.sleep()#休眠
    # time.gmtime()#需要传个时间戳,不传就是UTC市区标准时间
    # time.localtime()#获取的本地时间
    # time.mktime()#传入元组模式,转换成时间戳
    # time.strftime('%Y-%M-%D %H:%M:%S')#转换成指定的格式2020-06-04 22:11:56
    print(time.strftime('%Y-%m-%d %H:%M:%S'))#格式化字符串,取当前时间
    print(time.strptime('2020-06-04 22:11:56','%Y-%m-%d %H:%M:%S'))#struct_time元组格式
    # time.ctime()#时间戳转换成时间字符串格式
    # time.asctime()#元组转换时间字符串格式

    print(datetime.datetime.now())#获取当前时间
    print(datetime.datetime.now()+datetime.timedelta(3))#获取当前时间往后推3天的时间
    print(datetime.datetime.now()+datetime.timedelta(-3))#获取当前时间往前推3天的时间
    print(datetime.datetime.now()+datetime.timedelta(hours=3))#获取当前时间往后推3小时的时间
  • 相关阅读:
    Rabbitmq整合SpringBoot
    linux下转pdf乱码
    invalid authentication data connection reset
    谷粒商城异步编排(三十一)
    KSA运行
    安装k8s缺少模块
    ansible安装
    Rabbitmq常见的模式
    Rabbitmq入门
    谷粒商城检索服务(三十)
  • 原文地址:https://www.cnblogs.com/anhao-world/p/13063522.html
Copyright © 2011-2022 走看看